diff --git a/.stats.yml b/.stats.yml index b669b06..8e1aa70 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 9 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-1ff30126e780960cb04d5855fb8e9227099f91e1a3293f656cfaad50e1d7eb1c.yml -openapi_spec_hash: 42c1034ce32cbe5410b124e577998de8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-a41dc66f0aa3dbc9e8fe1da75f1101cbcb2fac79f728de42e4877cfe1bde3b6e.yml +openapi_spec_hash: 63c1a53e0899fb63a514dad395fd48f9 config_hash: 4b10254ea5b8e26ce632222b94a918aa diff --git a/README.md b/README.md index f46d20e..5630a60 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ import com.branddev.api.client.okhttp.BrandDevOkHttpClient; BrandDevClient client = BrandDevOkHttpClient.builder() // Configures using the `branddev.apiKey` and `branddev.baseUrl` system properties - Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables + // Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables .fromEnv() .apiKey("My API Key") .build(); @@ -231,6 +231,8 @@ The SDK throws custom unchecked exception types: - [`BrandDevIoException`](brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevIoException.kt): I/O networking errors. +- [`BrandDevRetryableException`](brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevRetryableException.kt): Generic error indicating a failure that could be retried by the client. + - [`BrandDevInvalidDataException`](brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. - [`BrandDevException`](brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. @@ -251,6 +253,12 @@ Or to `debug` for more verbose logging: $ export BRAND_DEV_LOG=debug ``` +## ProGuard and R8 + +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `brand-dev-java-core` is published with a [configuration file](brand-dev-java-core/src/main/resources/META-INF/proguard/brand-dev-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + ## Jackson The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. @@ -266,7 +274,7 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t ### Retries -The SDK automatically retries 2 times by default, with a short exponential backoff. +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. Only the following error types are retried: @@ -276,7 +284,7 @@ Only the following error types are retried: - 429 Rate Limit - 5xx Internal -The API may also explicitly instruct the SDK to retry or not retry a response. +The API may also explicitly instruct the SDK to retry or not retry a request. To set a custom number of retries, configure the client using the `maxRetries` method: 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 8ecc0b0..f3fa903 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 @@ -7,6 +7,7 @@ import com.branddev.api.client.BrandDevClientImpl 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.HttpClient import com.branddev.api.core.http.QueryParams import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.databind.json.JsonMapper @@ -19,13 +20,22 @@ import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import kotlin.jvm.optionals.getOrNull +/** + * A class that allows building an instance of [BrandDevClient] with [OkHttpClient] as the + * underlying [HttpClient]. + */ class BrandDevOkHttpClient private constructor() { companion object { - /** Returns a mutable builder for constructing an instance of [BrandDevOkHttpClient]. */ + /** Returns a mutable builder for constructing an instance of [BrandDevClient]. */ @JvmStatic fun builder() = Builder() + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ @JvmStatic fun fromEnv(): BrandDevClient = builder().fromEnv().build() } @@ -102,19 +112,49 @@ class BrandDevOkHttpClient private constructor() { clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.branddev.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.brand.dev/v1`. + */ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { clientOptions.responseValidation(responseValidation) } + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } /** @@ -126,6 +166,21 @@ class BrandDevOkHttpClient private constructor() { */ fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } @@ -210,6 +265,11 @@ class BrandDevOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ fun fromEnv() = apply { clientOptions.fromEnv() } /** 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 8940bdc..0da4c42 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 @@ -7,6 +7,7 @@ import com.branddev.api.client.BrandDevClientAsyncImpl 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.HttpClient import com.branddev.api.core.http.QueryParams import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.databind.json.JsonMapper @@ -19,15 +20,22 @@ import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import kotlin.jvm.optionals.getOrNull +/** + * A class that allows building an instance of [BrandDevClientAsync] with [OkHttpClient] as the + * underlying [HttpClient]. + */ class BrandDevOkHttpClientAsync private constructor() { companion object { - /** - * Returns a mutable builder for constructing an instance of [BrandDevOkHttpClientAsync]. - */ + /** Returns a mutable builder for constructing an instance of [BrandDevClientAsync]. */ @JvmStatic fun builder() = Builder() + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ @JvmStatic fun fromEnv(): BrandDevClientAsync = builder().fromEnv().build() } @@ -104,19 +112,49 @@ class BrandDevOkHttpClientAsync private constructor() { clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.branddev.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.brand.dev/v1`. + */ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { clientOptions.responseValidation(responseValidation) } + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } /** @@ -128,6 +166,21 @@ class BrandDevOkHttpClientAsync private constructor() { */ fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } @@ -212,6 +265,11 @@ class BrandDevOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ fun fromEnv() = apply { clientOptions.fromEnv() } /** 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 5caaadc..fffc543 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 @@ -13,9 +13,15 @@ import java.time.Duration import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** A class representing the SDK client configuration. */ class ClientOptions private constructor( private val originalHttpClient: HttpClient, + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `brand-dev-java-client-okhttp` or implement your own. + */ @get:JvmName("httpClient") val httpClient: HttpClient, /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -25,13 +31,55 @@ private constructor( * the SDK will work correctly when using an incompatible Jackson version. */ @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.branddev.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ @get:JvmName("clock") val clock: Clock, private val baseUrl: String?, + /** Headers to send with the request. */ @get:JvmName("headers") val headers: Headers, + /** Query params to send with the request. */ @get:JvmName("queryParams") val queryParams: QueryParams, + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ @get:JvmName("responseValidation") val responseValidation: Boolean, + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ @get:JvmName("timeout") val timeout: Timeout, + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String, ) { @@ -42,6 +90,11 @@ private constructor( } } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.brand.dev/v1`. + */ fun baseUrl(): String = baseUrl ?: PRODUCTION_URL fun toBuilder() = Builder().from(this) @@ -61,6 +114,11 @@ private constructor( */ @JvmStatic fun builder() = Builder() + /** + * Returns options configured using system properties and environment variables. + * + * @see Builder.fromEnv + */ @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } @@ -94,6 +152,11 @@ private constructor( apiKey = clientOptions.apiKey } + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `brand-dev-java-client-okhttp` or implement your own. + */ fun httpClient(httpClient: HttpClient) = apply { this.httpClient = PhantomReachableClosingHttpClient(httpClient) } @@ -109,19 +172,49 @@ private constructor( this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility } + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.branddev.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ fun clock(clock: Clock) = apply { this.clock = clock } + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.brand.dev/v1`. + */ fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ fun timeout(timeout: Timeout) = apply { this.timeout = timeout } /** @@ -133,6 +226,21 @@ private constructor( */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } @@ -219,6 +327,18 @@ private constructor( fun timeout(): Timeout = timeout + /** + * Updates configuration using system properties and environment variables. + * + * See this table for the available options: + * + * |Setter |System property |Environment variable|Required|Default value | + * |---------|------------------|--------------------|--------|----------------------------| + * |`apiKey` |`branddev.apiKey` |`BRAND_DEV_API_KEY` |true |- | + * |`baseUrl`|`branddev.baseUrl`|`BRAND_DEV_BASE_URL`|true |`"https://api.brand.dev/v1"`| + * + * System properties take precedence over environment variables. + */ fun fromEnv() = apply { (System.getProperty("branddev.baseUrl") ?: System.getenv("BRAND_DEV_BASE_URL"))?.let { baseUrl(it) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/RetryingHttpClient.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/RetryingHttpClient.kt index 66eba67..4c57529 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/RetryingHttpClient.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/RetryingHttpClient.kt @@ -3,6 +3,7 @@ package com.branddev.api.core.http import com.branddev.api.core.RequestOptions import com.branddev.api.core.checkRequired import com.branddev.api.errors.BrandDevIoException +import com.branddev.api.errors.BrandDevRetryableException import java.io.IOException import java.time.Clock import java.time.Duration @@ -176,9 +177,10 @@ private constructor( } private fun shouldRetry(throwable: Throwable): Boolean = - // Only retry IOException and BrandDevIoException, other exceptions are not intended to be - // retried. - throwable is IOException || throwable is BrandDevIoException + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is BrandDevIoException || + throwable is BrandDevRetryableException private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevRetryableException.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevRetryableException.kt new file mode 100644 index 0000000..c30df5b --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/errors/BrandDevRetryableException.kt @@ -0,0 +1,14 @@ +package com.branddev.api.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class BrandDevRetryableException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : BrandDevException(message, cause) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt index 7e5b1e1..8dc2a46 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt @@ -98,8 +98,10 @@ private constructor( fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryResponse.kt index 3bb860c..3ab340e 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryResponse.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryResponse.kt @@ -31,7 +31,6 @@ import kotlin.jvm.optionals.getOrNull class BrandAiQueryResponse private constructor( - private val code: JsonField, private val dataExtracted: JsonField>, private val domain: JsonField, private val status: JsonField, @@ -41,7 +40,6 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), @JsonProperty("data_extracted") @ExcludeMissing dataExtracted: JsonField> = JsonMissing.of(), @@ -50,15 +48,7 @@ private constructor( @JsonProperty("urls_analyzed") @ExcludeMissing urlsAnalyzed: JsonField> = JsonMissing.of(), - ) : this(code, dataExtracted, domain, status, urlsAnalyzed, mutableMapOf()) - - /** - * HTTP status code - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun code(): Optional = code.getOptional("code") + ) : this(dataExtracted, domain, status, urlsAnalyzed, mutableMapOf()) /** * Array of extracted data points @@ -92,13 +82,6 @@ private constructor( */ fun urlsAnalyzed(): Optional> = urlsAnalyzed.getOptional("urls_analyzed") - /** - * Returns the raw JSON value of [code]. - * - * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - /** * Returns the raw JSON value of [dataExtracted]. * @@ -152,7 +135,6 @@ private constructor( /** A builder for [BrandAiQueryResponse]. */ class Builder internal constructor() { - private var code: JsonField = JsonMissing.of() private var dataExtracted: JsonField>? = null private var domain: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() @@ -161,7 +143,6 @@ private constructor( @JvmSynthetic internal fun from(brandAiQueryResponse: BrandAiQueryResponse) = apply { - code = brandAiQueryResponse.code dataExtracted = brandAiQueryResponse.dataExtracted.map { it.toMutableList() } domain = brandAiQueryResponse.domain status = brandAiQueryResponse.status @@ -169,17 +150,6 @@ private constructor( additionalProperties = brandAiQueryResponse.additionalProperties.toMutableMap() } - /** HTTP status code */ - fun code(code: Long) = code(JsonField.of(code)) - - /** - * Sets [Builder.code] to an arbitrary JSON value. - * - * You should usually call [Builder.code] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun code(code: JsonField) = apply { this.code = code } - /** Array of extracted data points */ fun dataExtracted(dataExtracted: List) = dataExtracted(JsonField.of(dataExtracted)) @@ -281,7 +251,6 @@ private constructor( */ fun build(): BrandAiQueryResponse = BrandAiQueryResponse( - code, (dataExtracted ?: JsonMissing.of()).map { it.toImmutable() }, domain, status, @@ -297,7 +266,6 @@ private constructor( return@apply } - code() dataExtracted().ifPresent { it.forEach { it.validate() } } domain() status() @@ -320,8 +288,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (code.asKnown().isPresent) 1 else 0) + - (dataExtracted.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (dataExtracted.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (domain.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + (urlsAnalyzed.asKnown().getOrNull()?.size ?: 0) @@ -656,9 +623,12 @@ private constructor( @JvmStatic fun ofBool(bool: Boolean) = DatapointValue(bool = bool) - @JvmStatic fun ofStrings(strings: List) = DatapointValue(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = + DatapointValue(strings = strings.toImmutable()) - @JvmStatic fun ofNumber(number: List) = DatapointValue(number = number) + @JvmStatic + fun ofNumber(number: List) = DatapointValue(number = number.toImmutable()) } /** @@ -774,15 +744,15 @@ private constructor( return true } - return /* spotless:off */ other is BrandAiQueryResponse && code == other.code && dataExtracted == other.dataExtracted && domain == other.domain && status == other.status && urlsAnalyzed == other.urlsAnalyzed && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BrandAiQueryResponse && dataExtracted == other.dataExtracted && domain == other.domain && status == other.status && urlsAnalyzed == other.urlsAnalyzed && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, dataExtracted, domain, status, urlsAnalyzed, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(dataExtracted, domain, status, urlsAnalyzed, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BrandAiQueryResponse{code=$code, dataExtracted=$dataExtracted, domain=$domain, status=$status, urlsAnalyzed=$urlsAnalyzed, additionalProperties=$additionalProperties}" + "BrandAiQueryResponse{dataExtracted=$dataExtracted, domain=$domain, status=$status, urlsAnalyzed=$urlsAnalyzed, additionalProperties=$additionalProperties}" } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt index 6cbcd35..78cc4cd 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt @@ -32,8 +32,10 @@ private constructor( */ fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) 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 b4b3d1a..720e359 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 @@ -2,6 +2,7 @@ package com.branddev.api.models.brand +import com.branddev.api.core.Enum import com.branddev.api.core.ExcludeMissing import com.branddev.api.core.JsonField import com.branddev.api.core.JsonMissing @@ -224,8 +225,10 @@ private constructor( private val colors: JsonField>, private val description: JsonField, private val domain: JsonField, + private val email: JsonField, private val isNsfw: JsonField, private val logos: JsonField>, + private val phone: JsonField, private val slogan: JsonField, private val socials: JsonField>, private val stock: JsonField, @@ -246,8 +249,10 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), @JsonProperty("is_nsfw") @ExcludeMissing isNsfw: JsonField = JsonMissing.of(), @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), + @JsonProperty("phone") @ExcludeMissing phone: JsonField = JsonMissing.of(), @JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(), @JsonProperty("socials") @ExcludeMissing @@ -260,8 +265,10 @@ private constructor( colors, description, domain, + email, isNsfw, logos, + phone, slogan, socials, stock, @@ -309,6 +316,14 @@ private constructor( */ fun domain(): Optional = domain.getOptional("domain") + /** + * Company email address + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + /** * Indicates whether the brand content is not safe for work (NSFW) * @@ -325,6 +340,14 @@ private constructor( */ fun logos(): Optional> = logos.getOptional("logos") + /** + * Company phone number + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun phone(): Optional = phone.getOptional("phone") + /** * The brand's slogan * @@ -396,6 +419,13 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + /** * Returns the raw JSON value of [isNsfw]. * @@ -410,6 +440,13 @@ private constructor( */ @JsonProperty("logos") @ExcludeMissing fun _logos(): JsonField> = logos + /** + * Returns the raw JSON value of [phone]. + * + * Unlike [phone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone + /** * Returns the raw JSON value of [slogan]. * @@ -464,8 +501,10 @@ private constructor( private var colors: JsonField>? = null private var description: JsonField = JsonMissing.of() private var domain: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() private var isNsfw: JsonField = JsonMissing.of() private var logos: JsonField>? = null + private var phone: JsonField = JsonMissing.of() private var slogan: JsonField = JsonMissing.of() private var socials: JsonField>? = null private var stock: JsonField = JsonMissing.of() @@ -479,8 +518,10 @@ private constructor( colors = brand.colors.map { it.toMutableList() } description = brand.description domain = brand.domain + email = brand.email isNsfw = brand.isNsfw logos = brand.logos.map { it.toMutableList() } + phone = brand.phone slogan = brand.slogan socials = brand.socials.map { it.toMutableList() } stock = brand.stock @@ -578,6 +619,18 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } + /** Company email address */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + /** Indicates whether the brand content is not safe for work (NSFW) */ fun isNsfw(isNsfw: Boolean) = isNsfw(JsonField.of(isNsfw)) @@ -616,6 +669,18 @@ private constructor( } } + /** Company phone number */ + fun phone(phone: String) = phone(JsonField.of(phone)) + + /** + * Sets [Builder.phone] to an arbitrary JSON value. + * + * You should usually call [Builder.phone] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phone(phone: JsonField) = apply { this.phone = phone } + /** The brand's slogan */ fun slogan(slogan: String) = slogan(JsonField.of(slogan)) @@ -712,8 +777,10 @@ private constructor( (colors ?: JsonMissing.of()).map { it.toImmutable() }, description, domain, + email, isNsfw, (logos ?: JsonMissing.of()).map { it.toImmutable() }, + phone, slogan, (socials ?: JsonMissing.of()).map { it.toImmutable() }, stock, @@ -734,8 +801,10 @@ private constructor( colors().ifPresent { it.forEach { it.validate() } } description() domain() + email() isNsfw() logos().ifPresent { it.forEach { it.validate() } } + phone() slogan() socials().ifPresent { it.forEach { it.validate() } } stock().ifPresent { it.validate() } @@ -764,8 +833,10 @@ private constructor( (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (domain.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + (if (isNsfw.asKnown().isPresent) 1 else 0) + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (phone.asKnown().isPresent) 1 else 0) + (if (slogan.asKnown().isPresent) 1 else 0) + (socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (stock.asKnown().getOrNull()?.validity() ?: 0) + @@ -1567,6 +1638,7 @@ private constructor( /** Resolution of the backdrop image */ class Resolution private constructor( + private val aspectRatio: JsonField, private val height: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, @@ -1574,11 +1646,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("aspect_ratio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), - ) : this(height, width, mutableMapOf()) + ) : this(aspectRatio, height, width, mutableMapOf()) + + /** + * Aspect ratio of the image (width/height) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspect_ratio") /** * Height of the image in pixels @@ -1596,6 +1679,16 @@ private constructor( */ fun width(): Optional = width.getOptional("width") + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aspect_ratio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + /** * Returns the raw JSON value of [height]. * @@ -1633,17 +1726,33 @@ private constructor( /** A builder for [Resolution]. */ class Builder internal constructor() { + private var aspectRatio: JsonField = JsonMissing.of() private var height: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(resolution: Resolution) = apply { + aspectRatio = resolution.aspectRatio height = resolution.height width = resolution.width additionalProperties = resolution.additionalProperties.toMutableMap() } + /** Aspect ratio of the image (width/height) */ + fun aspectRatio(aspectRatio: Double) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + /** Height of the image in pixels */ fun height(height: Long) = height(JsonField.of(height)) @@ -1696,7 +1805,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Resolution = - Resolution(height, width, additionalProperties.toMutableMap()) + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -1706,6 +1815,7 @@ private constructor( return@apply } + aspectRatio() height() width() validated = true @@ -1727,7 +1837,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (height.asKnown().isPresent) 1 else 0) + + (if (aspectRatio.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -1735,17 +1846,17 @@ private constructor( return true } - return /* spotless:off */ other is Resolution && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Resolution && aspectRatio == other.aspectRatio && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(height, width, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(aspectRatio, height, width, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Resolution{height=$height, width=$width, additionalProperties=$additionalProperties}" + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1946,9 +2057,9 @@ private constructor( class Logo private constructor( private val colors: JsonField>, - private val group: JsonField, - private val mode: JsonField, + private val mode: JsonField, private val resolution: JsonField, + private val type: JsonField, private val url: JsonField, private val additionalProperties: MutableMap, ) { @@ -1958,13 +2069,13 @@ private constructor( @JsonProperty("colors") @ExcludeMissing colors: JsonField> = JsonMissing.of(), - @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), - @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), @JsonProperty("resolution") @ExcludeMissing resolution: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - ) : this(colors, group, mode, resolution, url, mutableMapOf()) + ) : this(colors, mode, resolution, type, url, mutableMapOf()) /** * Array of colors in the logo @@ -1975,31 +2086,33 @@ private constructor( fun colors(): Optional> = colors.getOptional("colors") /** - * Group identifier for logos + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun group(): Optional = group.getOptional("group") + fun mode(): Optional = mode.getOptional("mode") /** - * Mode of the logo, e.g., 'dark', 'light' + * Resolution of the logo image * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun mode(): Optional = mode.getOptional("mode") + fun resolution(): Optional = resolution.getOptional("resolution") /** - * Resolution of the logo image + * Type of the logo based on resolution (e.g., 'icon', 'logo') * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun resolution(): Optional = resolution.getOptional("resolution") + fun type(): Optional = type.getOptional("type") /** - * URL of the logo image + * CDN hosted url of the logo (ready for display) * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -2013,19 +2126,12 @@ private constructor( */ @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField> = colors - /** - * Returns the raw JSON value of [group]. - * - * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group - /** * Returns the raw JSON value of [mode]. * * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode /** * Returns the raw JSON value of [resolution]. @@ -2037,6 +2143,13 @@ private constructor( @ExcludeMissing fun _resolution(): JsonField = resolution + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** * Returns the raw JSON value of [url]. * @@ -2066,18 +2179,18 @@ private constructor( class Builder internal constructor() { private var colors: JsonField>? = null - private var group: JsonField = JsonMissing.of() - private var mode: JsonField = JsonMissing.of() + private var mode: JsonField = JsonMissing.of() private var resolution: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(logo: Logo) = apply { colors = logo.colors.map { it.toMutableList() } - group = logo.group mode = logo.mode resolution = logo.resolution + type = logo.type url = logo.url additionalProperties = logo.additionalProperties.toMutableMap() } @@ -2108,29 +2221,21 @@ private constructor( } } - /** Group identifier for logos */ - fun group(group: Long) = group(JsonField.of(group)) - /** - * Sets [Builder.group] to an arbitrary JSON value. - * - * You should usually call [Builder.group] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = + * best for dark mode, 'has_opaque_background' = can be used for either as image has + * its own background */ - fun group(group: JsonField) = apply { this.group = group } - - /** Mode of the logo, e.g., 'dark', 'light' */ - fun mode(mode: String) = mode(JsonField.of(mode)) + fun mode(mode: Mode) = mode(JsonField.of(mode)) /** * Sets [Builder.mode] to an arbitrary JSON value. * - * You should usually call [Builder.mode] with a well-typed [String] value instead. + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun mode(mode: JsonField) = apply { this.mode = mode } + fun mode(mode: JsonField) = apply { this.mode = mode } /** Resolution of the logo image */ fun resolution(resolution: Resolution) = resolution(JsonField.of(resolution)) @@ -2146,7 +2251,19 @@ private constructor( this.resolution = resolution } - /** URL of the logo image */ + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** CDN hosted url of the logo (ready for display) */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2188,9 +2305,9 @@ private constructor( fun build(): Logo = Logo( (colors ?: JsonMissing.of()).map { it.toImmutable() }, - group, mode, resolution, + type, url, additionalProperties.toMutableMap(), ) @@ -2204,9 +2321,9 @@ private constructor( } colors().ifPresent { it.forEach { it.validate() } } - group() - mode() + mode().ifPresent { it.validate() } resolution().ifPresent { it.validate() } + type().ifPresent { it.validate() } url() validated = true } @@ -2228,9 +2345,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (group.asKnown().isPresent) 1 else 0) + - (if (mode.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + (resolution.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (url.asKnown().isPresent) 1 else 0) class Color @@ -2412,9 +2529,151 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } + /** + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background + */ + class Mode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIGHT = of("light") + + @JvmField val DARK = of("dark") + + @JvmField val HAS_OPAQUE_BACKGROUND = of("has_opaque_background") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + /** + * An enum member indicating that [Mode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIGHT -> Value.LIGHT + DARK -> Value.DARK + HAS_OPAQUE_BACKGROUND -> Value.HAS_OPAQUE_BACKGROUND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIGHT -> Known.LIGHT + DARK -> Known.DARK + HAS_OPAQUE_BACKGROUND -> Known.HAS_OPAQUE_BACKGROUND + else -> throw BrandDevInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** Resolution of the logo image */ class Resolution private constructor( + private val aspectRatio: JsonField, private val height: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, @@ -2422,11 +2681,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("aspect_ratio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), - ) : this(height, width, mutableMapOf()) + ) : this(aspectRatio, height, width, mutableMapOf()) + + /** + * Aspect ratio of the image (width/height) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspect_ratio") /** * Height of the image in pixels @@ -2444,6 +2714,16 @@ private constructor( */ fun width(): Optional = width.getOptional("width") + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aspect_ratio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + /** * Returns the raw JSON value of [height]. * @@ -2481,17 +2761,33 @@ private constructor( /** A builder for [Resolution]. */ class Builder internal constructor() { + private var aspectRatio: JsonField = JsonMissing.of() private var height: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(resolution: Resolution) = apply { + aspectRatio = resolution.aspectRatio height = resolution.height width = resolution.width additionalProperties = resolution.additionalProperties.toMutableMap() } + /** Aspect ratio of the image (width/height) */ + fun aspectRatio(aspectRatio: Double) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + /** Height of the image in pixels */ fun height(height: Long) = height(JsonField.of(height)) @@ -2544,7 +2840,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Resolution = - Resolution(height, width, additionalProperties.toMutableMap()) + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -2554,6 +2850,7 @@ private constructor( return@apply } + aspectRatio() height() width() validated = true @@ -2575,7 +2872,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (height.asKnown().isPresent) 1 else 0) + + (if (aspectRatio.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2583,17 +2881,148 @@ private constructor( return true } - return /* spotless:off */ other is Resolution && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Resolution && aspectRatio == other.aspectRatio && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(height, width, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(aspectRatio, height, width, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Resolution{height=$height, width=$width, additionalProperties=$additionalProperties}" + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" + } + + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ICON = of("icon") + + @JvmField val LOGO = of("logo") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ICON, + LOGO, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ICON, + LOGO, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ICON -> Value.ICON + LOGO -> Value.LOGO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ICON -> Known.ICON + LOGO -> Known.LOGO + else -> throw BrandDevInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2601,17 +3030,17 @@ private constructor( return true } - return /* spotless:off */ other is Logo && colors == other.colors && group == other.group && mode == other.mode && resolution == other.resolution && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Logo && colors == other.colors && mode == other.mode && resolution == other.resolution && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(colors, group, mode, resolution, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(colors, mode, resolution, type, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Logo{colors=$colors, group=$group, mode=$mode, resolution=$resolution, url=$url, additionalProperties=$additionalProperties}" + "Logo{colors=$colors, mode=$mode, resolution=$resolution, type=$type, url=$url, additionalProperties=$additionalProperties}" } class Social @@ -2980,17 +3409,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 && isNsfw == other.isNsfw && 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 && email == other.email && isNsfw == other.isNsfw && logos == other.logos && phone == other.phone && 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, isNsfw, logos, slogan, socials, stock, title, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, email, isNsfw, logos, phone, 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, isNsfw=$isNsfw, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" + "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, email=$email, isNsfw=$isNsfw, logos=$logos, phone=$phone, 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/BrandPrefetchParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt index f88713a..880e240 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt @@ -65,8 +65,10 @@ private constructor( fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt index 9d48064..4822d2b 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt @@ -29,8 +29,10 @@ private constructor( */ fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) 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 322f4c3..b3f55d6 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 @@ -2,6 +2,7 @@ package com.branddev.api.models.brand +import com.branddev.api.core.Enum import com.branddev.api.core.ExcludeMissing import com.branddev.api.core.JsonField import com.branddev.api.core.JsonMissing @@ -216,8 +217,10 @@ private constructor( private val colors: JsonField>, private val description: JsonField, private val domain: JsonField, + private val email: JsonField, private val isNsfw: JsonField, private val logos: JsonField>, + private val phone: JsonField, private val slogan: JsonField, private val socials: JsonField>, private val stock: JsonField, @@ -238,8 +241,10 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), @JsonProperty("is_nsfw") @ExcludeMissing isNsfw: JsonField = JsonMissing.of(), @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), + @JsonProperty("phone") @ExcludeMissing phone: JsonField = JsonMissing.of(), @JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(), @JsonProperty("socials") @ExcludeMissing @@ -252,8 +257,10 @@ private constructor( colors, description, domain, + email, isNsfw, logos, + phone, slogan, socials, stock, @@ -301,6 +308,14 @@ private constructor( */ fun domain(): Optional = domain.getOptional("domain") + /** + * Company email address + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + /** * Indicates whether the brand content is not safe for work (NSFW) * @@ -317,6 +332,14 @@ private constructor( */ fun logos(): Optional> = logos.getOptional("logos") + /** + * Company phone number + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun phone(): Optional = phone.getOptional("phone") + /** * The brand's slogan * @@ -388,6 +411,13 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + /** * Returns the raw JSON value of [isNsfw]. * @@ -402,6 +432,13 @@ private constructor( */ @JsonProperty("logos") @ExcludeMissing fun _logos(): JsonField> = logos + /** + * Returns the raw JSON value of [phone]. + * + * Unlike [phone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone + /** * Returns the raw JSON value of [slogan]. * @@ -456,8 +493,10 @@ private constructor( private var colors: JsonField>? = null private var description: JsonField = JsonMissing.of() private var domain: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() private var isNsfw: JsonField = JsonMissing.of() private var logos: JsonField>? = null + private var phone: JsonField = JsonMissing.of() private var slogan: JsonField = JsonMissing.of() private var socials: JsonField>? = null private var stock: JsonField = JsonMissing.of() @@ -471,8 +510,10 @@ private constructor( colors = brand.colors.map { it.toMutableList() } description = brand.description domain = brand.domain + email = brand.email isNsfw = brand.isNsfw logos = brand.logos.map { it.toMutableList() } + phone = brand.phone slogan = brand.slogan socials = brand.socials.map { it.toMutableList() } stock = brand.stock @@ -570,6 +611,18 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } + /** Company email address */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + /** Indicates whether the brand content is not safe for work (NSFW) */ fun isNsfw(isNsfw: Boolean) = isNsfw(JsonField.of(isNsfw)) @@ -608,6 +661,18 @@ private constructor( } } + /** Company phone number */ + fun phone(phone: String) = phone(JsonField.of(phone)) + + /** + * Sets [Builder.phone] to an arbitrary JSON value. + * + * You should usually call [Builder.phone] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phone(phone: JsonField) = apply { this.phone = phone } + /** The brand's slogan */ fun slogan(slogan: String) = slogan(JsonField.of(slogan)) @@ -704,8 +769,10 @@ private constructor( (colors ?: JsonMissing.of()).map { it.toImmutable() }, description, domain, + email, isNsfw, (logos ?: JsonMissing.of()).map { it.toImmutable() }, + phone, slogan, (socials ?: JsonMissing.of()).map { it.toImmutable() }, stock, @@ -726,8 +793,10 @@ private constructor( colors().ifPresent { it.forEach { it.validate() } } description() domain() + email() isNsfw() logos().ifPresent { it.forEach { it.validate() } } + phone() slogan() socials().ifPresent { it.forEach { it.validate() } } stock().ifPresent { it.validate() } @@ -756,8 +825,10 @@ private constructor( (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (domain.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + (if (isNsfw.asKnown().isPresent) 1 else 0) + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (phone.asKnown().isPresent) 1 else 0) + (if (slogan.asKnown().isPresent) 1 else 0) + (socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (stock.asKnown().getOrNull()?.validity() ?: 0) + @@ -1559,6 +1630,7 @@ private constructor( /** Resolution of the backdrop image */ class Resolution private constructor( + private val aspectRatio: JsonField, private val height: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, @@ -1566,11 +1638,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("aspect_ratio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), - ) : this(height, width, mutableMapOf()) + ) : this(aspectRatio, height, width, mutableMapOf()) + + /** + * Aspect ratio of the image (width/height) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspect_ratio") /** * Height of the image in pixels @@ -1588,6 +1671,16 @@ private constructor( */ fun width(): Optional = width.getOptional("width") + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aspect_ratio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + /** * Returns the raw JSON value of [height]. * @@ -1625,17 +1718,33 @@ private constructor( /** A builder for [Resolution]. */ class Builder internal constructor() { + private var aspectRatio: JsonField = JsonMissing.of() private var height: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(resolution: Resolution) = apply { + aspectRatio = resolution.aspectRatio height = resolution.height width = resolution.width additionalProperties = resolution.additionalProperties.toMutableMap() } + /** Aspect ratio of the image (width/height) */ + fun aspectRatio(aspectRatio: Double) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + /** Height of the image in pixels */ fun height(height: Long) = height(JsonField.of(height)) @@ -1688,7 +1797,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Resolution = - Resolution(height, width, additionalProperties.toMutableMap()) + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -1698,6 +1807,7 @@ private constructor( return@apply } + aspectRatio() height() width() validated = true @@ -1719,7 +1829,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (height.asKnown().isPresent) 1 else 0) + + (if (aspectRatio.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -1727,17 +1838,17 @@ private constructor( return true } - return /* spotless:off */ other is Resolution && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Resolution && aspectRatio == other.aspectRatio && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(height, width, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(aspectRatio, height, width, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Resolution{height=$height, width=$width, additionalProperties=$additionalProperties}" + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1938,9 +2049,9 @@ private constructor( class Logo private constructor( private val colors: JsonField>, - private val group: JsonField, - private val mode: JsonField, + private val mode: JsonField, private val resolution: JsonField, + private val type: JsonField, private val url: JsonField, private val additionalProperties: MutableMap, ) { @@ -1950,13 +2061,13 @@ private constructor( @JsonProperty("colors") @ExcludeMissing colors: JsonField> = JsonMissing.of(), - @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), - @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), @JsonProperty("resolution") @ExcludeMissing resolution: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - ) : this(colors, group, mode, resolution, url, mutableMapOf()) + ) : this(colors, mode, resolution, type, url, mutableMapOf()) /** * Array of colors in the logo @@ -1967,31 +2078,33 @@ private constructor( fun colors(): Optional> = colors.getOptional("colors") /** - * Group identifier for logos + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun group(): Optional = group.getOptional("group") + fun mode(): Optional = mode.getOptional("mode") /** - * Mode of the logo, e.g., 'dark', 'light' + * Resolution of the logo image * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun mode(): Optional = mode.getOptional("mode") + fun resolution(): Optional = resolution.getOptional("resolution") /** - * Resolution of the logo image + * Type of the logo based on resolution (e.g., 'icon', 'logo') * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun resolution(): Optional = resolution.getOptional("resolution") + fun type(): Optional = type.getOptional("type") /** - * URL of the logo image + * CDN hosted url of the logo (ready for display) * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -2005,19 +2118,12 @@ private constructor( */ @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField> = colors - /** - * Returns the raw JSON value of [group]. - * - * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group - /** * Returns the raw JSON value of [mode]. * * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode /** * Returns the raw JSON value of [resolution]. @@ -2029,6 +2135,13 @@ private constructor( @ExcludeMissing fun _resolution(): JsonField = resolution + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** * Returns the raw JSON value of [url]. * @@ -2058,18 +2171,18 @@ private constructor( class Builder internal constructor() { private var colors: JsonField>? = null - private var group: JsonField = JsonMissing.of() - private var mode: JsonField = JsonMissing.of() + private var mode: JsonField = JsonMissing.of() private var resolution: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(logo: Logo) = apply { colors = logo.colors.map { it.toMutableList() } - group = logo.group mode = logo.mode resolution = logo.resolution + type = logo.type url = logo.url additionalProperties = logo.additionalProperties.toMutableMap() } @@ -2100,29 +2213,21 @@ private constructor( } } - /** Group identifier for logos */ - fun group(group: Long) = group(JsonField.of(group)) - /** - * Sets [Builder.group] to an arbitrary JSON value. - * - * You should usually call [Builder.group] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = + * best for dark mode, 'has_opaque_background' = can be used for either as image has + * its own background */ - fun group(group: JsonField) = apply { this.group = group } - - /** Mode of the logo, e.g., 'dark', 'light' */ - fun mode(mode: String) = mode(JsonField.of(mode)) + fun mode(mode: Mode) = mode(JsonField.of(mode)) /** * Sets [Builder.mode] to an arbitrary JSON value. * - * You should usually call [Builder.mode] with a well-typed [String] value instead. + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun mode(mode: JsonField) = apply { this.mode = mode } + fun mode(mode: JsonField) = apply { this.mode = mode } /** Resolution of the logo image */ fun resolution(resolution: Resolution) = resolution(JsonField.of(resolution)) @@ -2138,7 +2243,19 @@ private constructor( this.resolution = resolution } - /** URL of the logo image */ + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** CDN hosted url of the logo (ready for display) */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2180,9 +2297,9 @@ private constructor( fun build(): Logo = Logo( (colors ?: JsonMissing.of()).map { it.toImmutable() }, - group, mode, resolution, + type, url, additionalProperties.toMutableMap(), ) @@ -2196,9 +2313,9 @@ private constructor( } colors().ifPresent { it.forEach { it.validate() } } - group() - mode() + mode().ifPresent { it.validate() } resolution().ifPresent { it.validate() } + type().ifPresent { it.validate() } url() validated = true } @@ -2220,9 +2337,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (group.asKnown().isPresent) 1 else 0) + - (if (mode.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + (resolution.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (url.asKnown().isPresent) 1 else 0) class Color @@ -2404,9 +2521,151 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } + /** + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background + */ + class Mode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIGHT = of("light") + + @JvmField val DARK = of("dark") + + @JvmField val HAS_OPAQUE_BACKGROUND = of("has_opaque_background") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + /** + * An enum member indicating that [Mode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIGHT -> Value.LIGHT + DARK -> Value.DARK + HAS_OPAQUE_BACKGROUND -> Value.HAS_OPAQUE_BACKGROUND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIGHT -> Known.LIGHT + DARK -> Known.DARK + HAS_OPAQUE_BACKGROUND -> Known.HAS_OPAQUE_BACKGROUND + else -> throw BrandDevInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** Resolution of the logo image */ class Resolution private constructor( + private val aspectRatio: JsonField, private val height: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, @@ -2414,11 +2673,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("aspect_ratio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), - ) : this(height, width, mutableMapOf()) + ) : this(aspectRatio, height, width, mutableMapOf()) + + /** + * Aspect ratio of the image (width/height) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspect_ratio") /** * Height of the image in pixels @@ -2436,6 +2706,16 @@ private constructor( */ fun width(): Optional = width.getOptional("width") + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aspect_ratio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + /** * Returns the raw JSON value of [height]. * @@ -2473,17 +2753,33 @@ private constructor( /** A builder for [Resolution]. */ class Builder internal constructor() { + private var aspectRatio: JsonField = JsonMissing.of() private var height: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(resolution: Resolution) = apply { + aspectRatio = resolution.aspectRatio height = resolution.height width = resolution.width additionalProperties = resolution.additionalProperties.toMutableMap() } + /** Aspect ratio of the image (width/height) */ + fun aspectRatio(aspectRatio: Double) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + /** Height of the image in pixels */ fun height(height: Long) = height(JsonField.of(height)) @@ -2536,7 +2832,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Resolution = - Resolution(height, width, additionalProperties.toMutableMap()) + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -2546,6 +2842,7 @@ private constructor( return@apply } + aspectRatio() height() width() validated = true @@ -2567,7 +2864,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (height.asKnown().isPresent) 1 else 0) + + (if (aspectRatio.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2575,17 +2873,148 @@ private constructor( return true } - return /* spotless:off */ other is Resolution && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Resolution && aspectRatio == other.aspectRatio && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(height, width, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(aspectRatio, height, width, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Resolution{height=$height, width=$width, additionalProperties=$additionalProperties}" + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" + } + + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ICON = of("icon") + + @JvmField val LOGO = of("logo") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ICON, + LOGO, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ICON, + LOGO, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ICON -> Value.ICON + LOGO -> Value.LOGO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ICON -> Known.ICON + LOGO -> Known.LOGO + else -> throw BrandDevInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2593,17 +3022,17 @@ private constructor( return true } - return /* spotless:off */ other is Logo && colors == other.colors && group == other.group && mode == other.mode && resolution == other.resolution && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Logo && colors == other.colors && mode == other.mode && resolution == other.resolution && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(colors, group, mode, resolution, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(colors, mode, resolution, type, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Logo{colors=$colors, group=$group, mode=$mode, resolution=$resolution, url=$url, additionalProperties=$additionalProperties}" + "Logo{colors=$colors, mode=$mode, resolution=$resolution, type=$type, url=$url, additionalProperties=$additionalProperties}" } class Social @@ -2972,17 +3401,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 && isNsfw == other.isNsfw && 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 && email == other.email && isNsfw == other.isNsfw && logos == other.logos && phone == other.phone && 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, isNsfw, logos, slogan, socials, stock, title, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, email, isNsfw, logos, phone, 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, isNsfw=$isNsfw, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" + "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, email=$email, isNsfw=$isNsfw, logos=$logos, phone=$phone, 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/BrandRetrieveNaicsParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt index d8057fe..040539b 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt @@ -33,8 +33,10 @@ private constructor( */ fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt index 8388e7a..90fc50f 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt @@ -44,8 +44,10 @@ private constructor( */ fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) 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 c600e14..e6e7991 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 @@ -2,6 +2,7 @@ package com.branddev.api.models.brand +import com.branddev.api.core.Enum import com.branddev.api.core.ExcludeMissing import com.branddev.api.core.JsonField import com.branddev.api.core.JsonMissing @@ -213,8 +214,10 @@ private constructor( private val colors: JsonField>, private val description: JsonField, private val domain: JsonField, + private val email: JsonField, private val isNsfw: JsonField, private val logos: JsonField>, + private val phone: JsonField, private val slogan: JsonField, private val socials: JsonField>, private val stock: JsonField, @@ -235,8 +238,10 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), @JsonProperty("is_nsfw") @ExcludeMissing isNsfw: JsonField = JsonMissing.of(), @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), + @JsonProperty("phone") @ExcludeMissing phone: JsonField = JsonMissing.of(), @JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(), @JsonProperty("socials") @ExcludeMissing @@ -249,8 +254,10 @@ private constructor( colors, description, domain, + email, isNsfw, logos, + phone, slogan, socials, stock, @@ -298,6 +305,14 @@ private constructor( */ fun domain(): Optional = domain.getOptional("domain") + /** + * Company email address + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + /** * Indicates whether the brand content is not safe for work (NSFW) * @@ -314,6 +329,14 @@ private constructor( */ fun logos(): Optional> = logos.getOptional("logos") + /** + * Company phone number + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun phone(): Optional = phone.getOptional("phone") + /** * The brand's slogan * @@ -385,6 +408,13 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + /** * Returns the raw JSON value of [isNsfw]. * @@ -399,6 +429,13 @@ private constructor( */ @JsonProperty("logos") @ExcludeMissing fun _logos(): JsonField> = logos + /** + * Returns the raw JSON value of [phone]. + * + * Unlike [phone], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone") @ExcludeMissing fun _phone(): JsonField = phone + /** * Returns the raw JSON value of [slogan]. * @@ -453,8 +490,10 @@ private constructor( private var colors: JsonField>? = null private var description: JsonField = JsonMissing.of() private var domain: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() private var isNsfw: JsonField = JsonMissing.of() private var logos: JsonField>? = null + private var phone: JsonField = JsonMissing.of() private var slogan: JsonField = JsonMissing.of() private var socials: JsonField>? = null private var stock: JsonField = JsonMissing.of() @@ -468,8 +507,10 @@ private constructor( colors = brand.colors.map { it.toMutableList() } description = brand.description domain = brand.domain + email = brand.email isNsfw = brand.isNsfw logos = brand.logos.map { it.toMutableList() } + phone = brand.phone slogan = brand.slogan socials = brand.socials.map { it.toMutableList() } stock = brand.stock @@ -567,6 +608,18 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } + /** Company email address */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + /** Indicates whether the brand content is not safe for work (NSFW) */ fun isNsfw(isNsfw: Boolean) = isNsfw(JsonField.of(isNsfw)) @@ -605,6 +658,18 @@ private constructor( } } + /** Company phone number */ + fun phone(phone: String) = phone(JsonField.of(phone)) + + /** + * Sets [Builder.phone] to an arbitrary JSON value. + * + * You should usually call [Builder.phone] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phone(phone: JsonField) = apply { this.phone = phone } + /** The brand's slogan */ fun slogan(slogan: String) = slogan(JsonField.of(slogan)) @@ -701,8 +766,10 @@ private constructor( (colors ?: JsonMissing.of()).map { it.toImmutable() }, description, domain, + email, isNsfw, (logos ?: JsonMissing.of()).map { it.toImmutable() }, + phone, slogan, (socials ?: JsonMissing.of()).map { it.toImmutable() }, stock, @@ -723,8 +790,10 @@ private constructor( colors().ifPresent { it.forEach { it.validate() } } description() domain() + email() isNsfw() logos().ifPresent { it.forEach { it.validate() } } + phone() slogan() socials().ifPresent { it.forEach { it.validate() } } stock().ifPresent { it.validate() } @@ -753,8 +822,10 @@ private constructor( (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (domain.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + (if (isNsfw.asKnown().isPresent) 1 else 0) + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (phone.asKnown().isPresent) 1 else 0) + (if (slogan.asKnown().isPresent) 1 else 0) + (socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (stock.asKnown().getOrNull()?.validity() ?: 0) + @@ -1556,6 +1627,7 @@ private constructor( /** Resolution of the backdrop image */ class Resolution private constructor( + private val aspectRatio: JsonField, private val height: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, @@ -1563,11 +1635,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("aspect_ratio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), - ) : this(height, width, mutableMapOf()) + ) : this(aspectRatio, height, width, mutableMapOf()) + + /** + * Aspect ratio of the image (width/height) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspect_ratio") /** * Height of the image in pixels @@ -1585,6 +1668,16 @@ private constructor( */ fun width(): Optional = width.getOptional("width") + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aspect_ratio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + /** * Returns the raw JSON value of [height]. * @@ -1622,17 +1715,33 @@ private constructor( /** A builder for [Resolution]. */ class Builder internal constructor() { + private var aspectRatio: JsonField = JsonMissing.of() private var height: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(resolution: Resolution) = apply { + aspectRatio = resolution.aspectRatio height = resolution.height width = resolution.width additionalProperties = resolution.additionalProperties.toMutableMap() } + /** Aspect ratio of the image (width/height) */ + fun aspectRatio(aspectRatio: Double) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + /** Height of the image in pixels */ fun height(height: Long) = height(JsonField.of(height)) @@ -1685,7 +1794,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Resolution = - Resolution(height, width, additionalProperties.toMutableMap()) + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -1695,6 +1804,7 @@ private constructor( return@apply } + aspectRatio() height() width() validated = true @@ -1716,7 +1826,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (height.asKnown().isPresent) 1 else 0) + + (if (aspectRatio.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -1724,17 +1835,17 @@ private constructor( return true } - return /* spotless:off */ other is Resolution && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Resolution && aspectRatio == other.aspectRatio && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(height, width, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(aspectRatio, height, width, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Resolution{height=$height, width=$width, additionalProperties=$additionalProperties}" + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1935,9 +2046,9 @@ private constructor( class Logo private constructor( private val colors: JsonField>, - private val group: JsonField, - private val mode: JsonField, + private val mode: JsonField, private val resolution: JsonField, + private val type: JsonField, private val url: JsonField, private val additionalProperties: MutableMap, ) { @@ -1947,13 +2058,13 @@ private constructor( @JsonProperty("colors") @ExcludeMissing colors: JsonField> = JsonMissing.of(), - @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), - @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), @JsonProperty("resolution") @ExcludeMissing resolution: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - ) : this(colors, group, mode, resolution, url, mutableMapOf()) + ) : this(colors, mode, resolution, type, url, mutableMapOf()) /** * Array of colors in the logo @@ -1964,31 +2075,33 @@ private constructor( fun colors(): Optional> = colors.getOptional("colors") /** - * Group identifier for logos + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun group(): Optional = group.getOptional("group") + fun mode(): Optional = mode.getOptional("mode") /** - * Mode of the logo, e.g., 'dark', 'light' + * Resolution of the logo image * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun mode(): Optional = mode.getOptional("mode") + fun resolution(): Optional = resolution.getOptional("resolution") /** - * Resolution of the logo image + * Type of the logo based on resolution (e.g., 'icon', 'logo') * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun resolution(): Optional = resolution.getOptional("resolution") + fun type(): Optional = type.getOptional("type") /** - * URL of the logo image + * CDN hosted url of the logo (ready for display) * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -2002,19 +2115,12 @@ private constructor( */ @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField> = colors - /** - * Returns the raw JSON value of [group]. - * - * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group - /** * Returns the raw JSON value of [mode]. * * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode /** * Returns the raw JSON value of [resolution]. @@ -2026,6 +2132,13 @@ private constructor( @ExcludeMissing fun _resolution(): JsonField = resolution + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** * Returns the raw JSON value of [url]. * @@ -2055,18 +2168,18 @@ private constructor( class Builder internal constructor() { private var colors: JsonField>? = null - private var group: JsonField = JsonMissing.of() - private var mode: JsonField = JsonMissing.of() + private var mode: JsonField = JsonMissing.of() private var resolution: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(logo: Logo) = apply { colors = logo.colors.map { it.toMutableList() } - group = logo.group mode = logo.mode resolution = logo.resolution + type = logo.type url = logo.url additionalProperties = logo.additionalProperties.toMutableMap() } @@ -2097,29 +2210,21 @@ private constructor( } } - /** Group identifier for logos */ - fun group(group: Long) = group(JsonField.of(group)) - /** - * Sets [Builder.group] to an arbitrary JSON value. - * - * You should usually call [Builder.group] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = + * best for dark mode, 'has_opaque_background' = can be used for either as image has + * its own background */ - fun group(group: JsonField) = apply { this.group = group } - - /** Mode of the logo, e.g., 'dark', 'light' */ - fun mode(mode: String) = mode(JsonField.of(mode)) + fun mode(mode: Mode) = mode(JsonField.of(mode)) /** * Sets [Builder.mode] to an arbitrary JSON value. * - * You should usually call [Builder.mode] with a well-typed [String] value instead. + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun mode(mode: JsonField) = apply { this.mode = mode } + fun mode(mode: JsonField) = apply { this.mode = mode } /** Resolution of the logo image */ fun resolution(resolution: Resolution) = resolution(JsonField.of(resolution)) @@ -2135,7 +2240,19 @@ private constructor( this.resolution = resolution } - /** URL of the logo image */ + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** CDN hosted url of the logo (ready for display) */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2177,9 +2294,9 @@ private constructor( fun build(): Logo = Logo( (colors ?: JsonMissing.of()).map { it.toImmutable() }, - group, mode, resolution, + type, url, additionalProperties.toMutableMap(), ) @@ -2193,9 +2310,9 @@ private constructor( } colors().ifPresent { it.forEach { it.validate() } } - group() - mode() + mode().ifPresent { it.validate() } resolution().ifPresent { it.validate() } + type().ifPresent { it.validate() } url() validated = true } @@ -2217,9 +2334,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (group.asKnown().isPresent) 1 else 0) + - (if (mode.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + (resolution.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (url.asKnown().isPresent) 1 else 0) class Color @@ -2401,9 +2518,151 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } + /** + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background + */ + class Mode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIGHT = of("light") + + @JvmField val DARK = of("dark") + + @JvmField val HAS_OPAQUE_BACKGROUND = of("has_opaque_background") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + /** + * An enum member indicating that [Mode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIGHT -> Value.LIGHT + DARK -> Value.DARK + HAS_OPAQUE_BACKGROUND -> Value.HAS_OPAQUE_BACKGROUND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIGHT -> Known.LIGHT + DARK -> Known.DARK + HAS_OPAQUE_BACKGROUND -> Known.HAS_OPAQUE_BACKGROUND + else -> throw BrandDevInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** Resolution of the logo image */ class Resolution private constructor( + private val aspectRatio: JsonField, private val height: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, @@ -2411,11 +2670,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("aspect_ratio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), - ) : this(height, width, mutableMapOf()) + ) : this(aspectRatio, height, width, mutableMapOf()) + + /** + * Aspect ratio of the image (width/height) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspect_ratio") /** * Height of the image in pixels @@ -2433,6 +2703,16 @@ private constructor( */ fun width(): Optional = width.getOptional("width") + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aspect_ratio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + /** * Returns the raw JSON value of [height]. * @@ -2470,17 +2750,33 @@ private constructor( /** A builder for [Resolution]. */ class Builder internal constructor() { + private var aspectRatio: JsonField = JsonMissing.of() private var height: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(resolution: Resolution) = apply { + aspectRatio = resolution.aspectRatio height = resolution.height width = resolution.width additionalProperties = resolution.additionalProperties.toMutableMap() } + /** Aspect ratio of the image (width/height) */ + fun aspectRatio(aspectRatio: Double) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + /** Height of the image in pixels */ fun height(height: Long) = height(JsonField.of(height)) @@ -2533,7 +2829,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Resolution = - Resolution(height, width, additionalProperties.toMutableMap()) + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -2543,6 +2839,7 @@ private constructor( return@apply } + aspectRatio() height() width() validated = true @@ -2564,7 +2861,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (height.asKnown().isPresent) 1 else 0) + + (if (aspectRatio.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2572,17 +2870,148 @@ private constructor( return true } - return /* spotless:off */ other is Resolution && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Resolution && aspectRatio == other.aspectRatio && height == other.height && width == other.width && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(height, width, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(aspectRatio, height, width, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Resolution{height=$height, width=$width, additionalProperties=$additionalProperties}" + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" + } + + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ICON = of("icon") + + @JvmField val LOGO = of("logo") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ICON, + LOGO, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ICON, + LOGO, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ICON -> Value.ICON + LOGO -> Value.LOGO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ICON -> Known.ICON + LOGO -> Known.LOGO + else -> throw BrandDevInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2590,17 +3019,17 @@ private constructor( return true } - return /* spotless:off */ other is Logo && colors == other.colors && group == other.group && mode == other.mode && resolution == other.resolution && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Logo && colors == other.colors && mode == other.mode && resolution == other.resolution && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(colors, group, mode, resolution, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(colors, mode, resolution, type, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Logo{colors=$colors, group=$group, mode=$mode, resolution=$resolution, url=$url, additionalProperties=$additionalProperties}" + "Logo{colors=$colors, mode=$mode, resolution=$resolution, type=$type, url=$url, additionalProperties=$additionalProperties}" } class Social @@ -2969,17 +3398,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 && isNsfw == other.isNsfw && 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 && email == other.email && isNsfw == other.isNsfw && logos == other.logos && phone == other.phone && 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, isNsfw, logos, slogan, socials, stock, title, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, email, isNsfw, logos, phone, 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, isNsfw=$isNsfw, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" + "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, email=$email, isNsfw=$isNsfw, logos=$logos, phone=$phone, 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/BrandRetrieveSimplifiedParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParams.kt index bd09908..722db94 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParams.kt @@ -33,8 +33,10 @@ private constructor( */ fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponse.kt index 9ca3a72..bd5b1a0 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponse.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponse.kt @@ -2,6 +2,7 @@ package com.branddev.api.models.brand +import com.branddev.api.core.Enum import com.branddev.api.core.ExcludeMissing import com.branddev.api.core.JsonField import com.branddev.api.core.JsonMissing @@ -1351,10 +1352,9 @@ private constructor( class Logo private constructor( private val colors: JsonField>, - private val group: JsonField, - private val mode: JsonField, + private val mode: JsonField, private val resolution: JsonField, - private val type: JsonField, + private val type: JsonField, private val url: JsonField, private val additionalProperties: MutableMap, ) { @@ -1364,14 +1364,13 @@ private constructor( @JsonProperty("colors") @ExcludeMissing colors: JsonField> = JsonMissing.of(), - @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), - @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), @JsonProperty("resolution") @ExcludeMissing resolution: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - ) : this(colors, group, mode, resolution, type, url, mutableMapOf()) + ) : this(colors, mode, resolution, type, url, mutableMapOf()) /** * Array of colors in the logo @@ -1382,20 +1381,14 @@ private constructor( fun colors(): Optional> = colors.getOptional("colors") /** - * Group identifier for logos + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun group(): Optional = group.getOptional("group") - - /** - * Mode of the logo, e.g., 'dark', 'light' - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun mode(): Optional = mode.getOptional("mode") + fun mode(): Optional = mode.getOptional("mode") /** * Resolution of the logo image @@ -1406,15 +1399,15 @@ private constructor( fun resolution(): Optional = resolution.getOptional("resolution") /** - * Type of the logo based on resolution (e.g., 'icon', 'logo', 'banner') + * Type of the logo based on resolution (e.g., 'icon', 'logo') * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun type(): Optional = type.getOptional("type") + fun type(): Optional = type.getOptional("type") /** - * URL of the logo image + * CDN hosted url of the logo (ready for display) * * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -1428,19 +1421,12 @@ private constructor( */ @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField> = colors - /** - * Returns the raw JSON value of [group]. - * - * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group - /** * Returns the raw JSON value of [mode]. * * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode /** * Returns the raw JSON value of [resolution]. @@ -1457,7 +1443,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [url]. @@ -1488,17 +1474,15 @@ private constructor( class Builder internal constructor() { private var colors: JsonField>? = null - private var group: JsonField = JsonMissing.of() - private var mode: JsonField = JsonMissing.of() + private var mode: JsonField = JsonMissing.of() private var resolution: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(logo: Logo) = apply { colors = logo.colors.map { it.toMutableList() } - group = logo.group mode = logo.mode resolution = logo.resolution type = logo.type @@ -1532,29 +1516,21 @@ private constructor( } } - /** Group identifier for logos */ - fun group(group: Long) = group(JsonField.of(group)) - /** - * Sets [Builder.group] to an arbitrary JSON value. - * - * You should usually call [Builder.group] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = + * best for dark mode, 'has_opaque_background' = can be used for either as image has + * its own background */ - fun group(group: JsonField) = apply { this.group = group } - - /** Mode of the logo, e.g., 'dark', 'light' */ - fun mode(mode: String) = mode(JsonField.of(mode)) + fun mode(mode: Mode) = mode(JsonField.of(mode)) /** * Sets [Builder.mode] to an arbitrary JSON value. * - * You should usually call [Builder.mode] with a well-typed [String] value instead. + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun mode(mode: JsonField) = apply { this.mode = mode } + fun mode(mode: JsonField) = apply { this.mode = mode } /** Resolution of the logo image */ fun resolution(resolution: Resolution) = resolution(JsonField.of(resolution)) @@ -1570,19 +1546,19 @@ private constructor( this.resolution = resolution } - /** Type of the logo based on resolution (e.g., 'icon', 'logo', 'banner') */ - fun type(type: String) = type(JsonField.of(type)) + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + fun type(type: Type) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [String] value instead. + * You should usually call [Builder.type] with a well-typed [Type] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } - /** URL of the logo image */ + /** CDN hosted url of the logo (ready for display) */ fun url(url: String) = url(JsonField.of(url)) /** @@ -1624,7 +1600,6 @@ private constructor( fun build(): Logo = Logo( (colors ?: JsonMissing.of()).map { it.toImmutable() }, - group, mode, resolution, type, @@ -1641,10 +1616,9 @@ private constructor( } colors().ifPresent { it.forEach { it.validate() } } - group() - mode() + mode().ifPresent { it.validate() } resolution().ifPresent { it.validate() } - type() + type().ifPresent { it.validate() } url() validated = true } @@ -1666,10 +1640,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (group.asKnown().isPresent) 1 else 0) + - (if (mode.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + (resolution.asKnown().getOrNull()?.validity() ?: 0) + - (if (type.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (url.asKnown().isPresent) 1 else 0) class Color @@ -1851,6 +1824,147 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } + /** + * Indicates when this logo is best used: 'light' = best for light mode, 'dark' = best + * for dark mode, 'has_opaque_background' = can be used for either as image has its own + * background + */ + class Mode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIGHT = of("light") + + @JvmField val DARK = of("dark") + + @JvmField val HAS_OPAQUE_BACKGROUND = of("has_opaque_background") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIGHT, + DARK, + HAS_OPAQUE_BACKGROUND, + /** + * An enum member indicating that [Mode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIGHT -> Value.LIGHT + DARK -> Value.DARK + HAS_OPAQUE_BACKGROUND -> Value.HAS_OPAQUE_BACKGROUND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIGHT -> Known.LIGHT + DARK -> Known.DARK + HAS_OPAQUE_BACKGROUND -> Known.HAS_OPAQUE_BACKGROUND + else -> throw BrandDevInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** Resolution of the logo image */ class Resolution private constructor( @@ -2075,22 +2189,153 @@ private constructor( "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" } + /** Type of the logo based on resolution (e.g., 'icon', 'logo') */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ICON = of("icon") + + @JvmField val LOGO = of("logo") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ICON, + LOGO, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ICON, + LOGO, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ICON -> Value.ICON + LOGO -> Value.LOGO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws BrandDevInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ICON -> Known.ICON + LOGO -> Known.LOGO + else -> throw BrandDevInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws BrandDevInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + BrandDevInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Logo && colors == other.colors && group == other.group && mode == other.mode && resolution == other.resolution && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Logo && colors == other.colors && mode == other.mode && resolution == other.resolution && type == other.type && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(colors, group, mode, resolution, type, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(colors, mode, resolution, type, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Logo{colors=$colors, group=$group, mode=$mode, resolution=$resolution, type=$type, url=$url, additionalProperties=$additionalProperties}" + "Logo{colors=$colors, mode=$mode, resolution=$resolution, type=$type, url=$url, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotParams.kt index 0fa8913..022a90e 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotParams.kt @@ -39,8 +39,10 @@ private constructor( */ fun fullScreenshot(): Optional = Optional.ofNullable(fullScreenshot) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideParams.kt index 3874bbf..6ccbad6 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideParams.kt @@ -35,8 +35,10 @@ private constructor( */ fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders + /** Additional query param to send with the request. */ fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) 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 02dd1d5..19cc5be 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 @@ -44,7 +44,7 @@ interface BrandServiceAsync { fun retrieve(params: BrandRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BrandRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -57,7 +57,7 @@ interface BrandServiceAsync { fun aiQuery(params: BrandAiQueryParams): CompletableFuture = aiQuery(params, RequestOptions.none()) - /** @see [aiQuery] */ + /** @see aiQuery */ fun aiQuery( params: BrandAiQueryParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -72,7 +72,7 @@ interface BrandServiceAsync { ): CompletableFuture = identifyFromTransaction(params, RequestOptions.none()) - /** @see [identifyFromTransaction] */ + /** @see identifyFromTransaction */ fun identifyFromTransaction( params: BrandIdentifyFromTransactionParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -86,7 +86,7 @@ interface BrandServiceAsync { fun prefetch(params: BrandPrefetchParams): CompletableFuture = prefetch(params, RequestOptions.none()) - /** @see [prefetch] */ + /** @see prefetch */ fun prefetch( params: BrandPrefetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -98,7 +98,7 @@ interface BrandServiceAsync { ): CompletableFuture = retrieveByTicker(params, RequestOptions.none()) - /** @see [retrieveByTicker] */ + /** @see retrieveByTicker */ fun retrieveByTicker( params: BrandRetrieveByTickerParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -109,7 +109,7 @@ interface BrandServiceAsync { params: BrandRetrieveNaicsParams ): CompletableFuture = retrieveNaics(params, RequestOptions.none()) - /** @see [retrieveNaics] */ + /** @see retrieveNaics */ fun retrieveNaics( params: BrandRetrieveNaicsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -125,7 +125,7 @@ interface BrandServiceAsync { ): CompletableFuture = retrieveSimplified(params, RequestOptions.none()) - /** @see [retrieveSimplified] */ + /** @see retrieveSimplified */ fun retrieveSimplified( params: BrandRetrieveSimplifiedParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -139,7 +139,7 @@ interface BrandServiceAsync { fun screenshot(params: BrandScreenshotParams): CompletableFuture = screenshot(params, RequestOptions.none()) - /** @see [screenshot] */ + /** @see screenshot */ fun screenshot( params: BrandScreenshotParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -152,7 +152,7 @@ interface BrandServiceAsync { fun styleguide(params: BrandStyleguideParams): CompletableFuture = styleguide(params, RequestOptions.none()) - /** @see [styleguide] */ + /** @see styleguide */ fun styleguide( params: BrandStyleguideParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -179,7 +179,7 @@ interface BrandServiceAsync { ): CompletableFuture> = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BrandRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -194,7 +194,7 @@ interface BrandServiceAsync { ): CompletableFuture> = aiQuery(params, RequestOptions.none()) - /** @see [aiQuery] */ + /** @see aiQuery */ fun aiQuery( params: BrandAiQueryParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -209,7 +209,7 @@ interface BrandServiceAsync { ): CompletableFuture> = identifyFromTransaction(params, RequestOptions.none()) - /** @see [identifyFromTransaction] */ + /** @see identifyFromTransaction */ fun identifyFromTransaction( params: BrandIdentifyFromTransactionParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -224,7 +224,7 @@ interface BrandServiceAsync { ): CompletableFuture> = prefetch(params, RequestOptions.none()) - /** @see [prefetch] */ + /** @see prefetch */ fun prefetch( params: BrandPrefetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -239,7 +239,7 @@ interface BrandServiceAsync { ): CompletableFuture> = retrieveByTicker(params, RequestOptions.none()) - /** @see [retrieveByTicker] */ + /** @see retrieveByTicker */ fun retrieveByTicker( params: BrandRetrieveByTickerParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -254,7 +254,7 @@ interface BrandServiceAsync { ): CompletableFuture> = retrieveNaics(params, RequestOptions.none()) - /** @see [retrieveNaics] */ + /** @see retrieveNaics */ fun retrieveNaics( params: BrandRetrieveNaicsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -269,7 +269,7 @@ interface BrandServiceAsync { ): CompletableFuture> = retrieveSimplified(params, RequestOptions.none()) - /** @see [retrieveSimplified] */ + /** @see retrieveSimplified */ fun retrieveSimplified( params: BrandRetrieveSimplifiedParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -284,7 +284,7 @@ interface BrandServiceAsync { ): CompletableFuture> = screenshot(params, RequestOptions.none()) - /** @see [screenshot] */ + /** @see screenshot */ fun screenshot( params: BrandScreenshotParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -299,7 +299,7 @@ interface BrandServiceAsync { ): CompletableFuture> = styleguide(params, RequestOptions.none()) - /** @see [styleguide] */ + /** @see styleguide */ fun styleguide( params: BrandStyleguideParams, requestOptions: RequestOptions = RequestOptions.none(), 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 d5f473c..8cca077 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 @@ -44,7 +44,7 @@ interface BrandService { fun retrieve(params: BrandRetrieveParams): BrandRetrieveResponse = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ fun retrieve( params: BrandRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -57,7 +57,7 @@ interface BrandService { fun aiQuery(params: BrandAiQueryParams): BrandAiQueryResponse = aiQuery(params, RequestOptions.none()) - /** @see [aiQuery] */ + /** @see aiQuery */ fun aiQuery( params: BrandAiQueryParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -71,7 +71,7 @@ interface BrandService { params: BrandIdentifyFromTransactionParams ): BrandIdentifyFromTransactionResponse = identifyFromTransaction(params, RequestOptions.none()) - /** @see [identifyFromTransaction] */ + /** @see identifyFromTransaction */ fun identifyFromTransaction( params: BrandIdentifyFromTransactionParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -85,7 +85,7 @@ interface BrandService { fun prefetch(params: BrandPrefetchParams): BrandPrefetchResponse = prefetch(params, RequestOptions.none()) - /** @see [prefetch] */ + /** @see prefetch */ fun prefetch( params: BrandPrefetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -95,7 +95,7 @@ interface BrandService { fun retrieveByTicker(params: BrandRetrieveByTickerParams): BrandRetrieveByTickerResponse = retrieveByTicker(params, RequestOptions.none()) - /** @see [retrieveByTicker] */ + /** @see retrieveByTicker */ fun retrieveByTicker( params: BrandRetrieveByTickerParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -105,7 +105,7 @@ interface BrandService { fun retrieveNaics(params: BrandRetrieveNaicsParams): BrandRetrieveNaicsResponse = retrieveNaics(params, RequestOptions.none()) - /** @see [retrieveNaics] */ + /** @see retrieveNaics */ fun retrieveNaics( params: BrandRetrieveNaicsParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -119,7 +119,7 @@ interface BrandService { fun retrieveSimplified(params: BrandRetrieveSimplifiedParams): BrandRetrieveSimplifiedResponse = retrieveSimplified(params, RequestOptions.none()) - /** @see [retrieveSimplified] */ + /** @see retrieveSimplified */ fun retrieveSimplified( params: BrandRetrieveSimplifiedParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -133,7 +133,7 @@ interface BrandService { fun screenshot(params: BrandScreenshotParams): BrandScreenshotResponse = screenshot(params, RequestOptions.none()) - /** @see [screenshot] */ + /** @see screenshot */ fun screenshot( params: BrandScreenshotParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -146,7 +146,7 @@ interface BrandService { fun styleguide(params: BrandStyleguideParams): BrandStyleguideResponse = styleguide(params, RequestOptions.none()) - /** @see [styleguide] */ + /** @see styleguide */ fun styleguide( params: BrandStyleguideParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -170,7 +170,7 @@ interface BrandService { fun retrieve(params: BrandRetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) - /** @see [retrieve] */ + /** @see retrieve */ @MustBeClosed fun retrieve( params: BrandRetrieveParams, @@ -185,7 +185,7 @@ interface BrandService { fun aiQuery(params: BrandAiQueryParams): HttpResponseFor = aiQuery(params, RequestOptions.none()) - /** @see [aiQuery] */ + /** @see aiQuery */ @MustBeClosed fun aiQuery( params: BrandAiQueryParams, @@ -202,7 +202,7 @@ interface BrandService { ): HttpResponseFor = identifyFromTransaction(params, RequestOptions.none()) - /** @see [identifyFromTransaction] */ + /** @see identifyFromTransaction */ @MustBeClosed fun identifyFromTransaction( params: BrandIdentifyFromTransactionParams, @@ -217,7 +217,7 @@ interface BrandService { fun prefetch(params: BrandPrefetchParams): HttpResponseFor = prefetch(params, RequestOptions.none()) - /** @see [prefetch] */ + /** @see prefetch */ @MustBeClosed fun prefetch( params: BrandPrefetchParams, @@ -234,7 +234,7 @@ interface BrandService { ): HttpResponseFor = retrieveByTicker(params, RequestOptions.none()) - /** @see [retrieveByTicker] */ + /** @see retrieveByTicker */ @MustBeClosed fun retrieveByTicker( params: BrandRetrieveByTickerParams, @@ -251,7 +251,7 @@ interface BrandService { ): HttpResponseFor = retrieveNaics(params, RequestOptions.none()) - /** @see [retrieveNaics] */ + /** @see retrieveNaics */ @MustBeClosed fun retrieveNaics( params: BrandRetrieveNaicsParams, @@ -268,7 +268,7 @@ interface BrandService { ): HttpResponseFor = retrieveSimplified(params, RequestOptions.none()) - /** @see [retrieveSimplified] */ + /** @see retrieveSimplified */ @MustBeClosed fun retrieveSimplified( params: BrandRetrieveSimplifiedParams, @@ -283,7 +283,7 @@ interface BrandService { fun screenshot(params: BrandScreenshotParams): HttpResponseFor = screenshot(params, RequestOptions.none()) - /** @see [screenshot] */ + /** @see screenshot */ @MustBeClosed fun screenshot( params: BrandScreenshotParams, @@ -298,7 +298,7 @@ interface BrandService { fun styleguide(params: BrandStyleguideParams): HttpResponseFor = styleguide(params, RequestOptions.none()) - /** @see [styleguide] */ + /** @see styleguide */ @MustBeClosed fun styleguide( params: BrandStyleguideParams, diff --git a/brand-dev-java-core/src/main/resources/META-INF/proguard/brand-dev-java-core.pro b/brand-dev-java-core/src/main/resources/META-INF/proguard/brand-dev-java-core.pro new file mode 100644 index 0000000..595d923 --- /dev/null +++ b/brand-dev-java-core/src/main/resources/META-INF/proguard/brand-dev-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reflection to access the default constructors of serializers and deserializers. +-keepclassmembers class * extends com.branddev.api.core.BaseSerializer { + (); +} +-keepclassmembers class * extends com.branddev.api.core.BaseDeserializer { + (); +} + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class com.branddev.api.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt index 6272d41..99ee82a 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt @@ -2,6 +2,7 @@ package com.branddev.api.core.http import com.branddev.api.client.okhttp.OkHttpClient import com.branddev.api.core.RequestOptions +import com.branddev.api.errors.BrandDevRetryableException import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest @@ -251,6 +252,82 @@ internal class RetryingHttpClientTest { assertNoResponseLeaks() } + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw BrandDevRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + callCount++ + if (callCount == 1) { + val future = CompletableFuture() + future.completeExceptionally( + BrandDevRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + private fun retryingHttpClientBuilder() = RetryingHttpClient.builder() .httpClient(httpClient) diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt index 207e7c2..4ea60b7 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt @@ -3,12 +3,10 @@ package com.branddev.api.models.brand import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandAiQueryParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandAiQueryParams.builder() @@ -37,7 +35,6 @@ internal class BrandAiQueryParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = @@ -94,7 +91,6 @@ internal class BrandAiQueryParamsTest { assertThat(body.timeoutMs()).contains(1L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryResponseTest.kt index f0faa74..876a673 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryResponseTest.kt @@ -6,17 +6,14 @@ import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandAiQueryResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandAiQueryResponse = BrandAiQueryResponse.builder() - .code(0L) .addDataExtracted( BrandAiQueryResponse.DataExtracted.builder() .datapointName("datapoint_name") @@ -28,7 +25,6 @@ internal class BrandAiQueryResponseTest { .addUrlsAnalyzed("string") .build() - assertThat(brandAiQueryResponse.code()).contains(0L) assertThat(brandAiQueryResponse.dataExtracted().getOrNull()) .containsExactly( BrandAiQueryResponse.DataExtracted.builder() @@ -41,13 +37,11 @@ internal class BrandAiQueryResponseTest { assertThat(brandAiQueryResponse.urlsAnalyzed().getOrNull()).containsExactly("string") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() val brandAiQueryResponse = BrandAiQueryResponse.builder() - .code(0L) .addDataExtracted( BrandAiQueryResponse.DataExtracted.builder() .datapointName("datapoint_name") diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt index 0eef281..e23f6fe 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt @@ -4,12 +4,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandIdentifyFromTransactionParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandIdentifyFromTransactionParams.builder() @@ -18,7 +16,6 @@ internal class BrandIdentifyFromTransactionParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -38,7 +35,6 @@ internal class BrandIdentifyFromTransactionParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt index 7913136..a98f811 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandIdentifyFromTransactionResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandIdentifyFromTransactionResponse = @@ -40,6 +38,7 @@ internal class BrandIdentifyFromTransactionResponseTest { .resolution( BrandIdentifyFromTransactionResponse.Brand.Backdrop.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -55,6 +54,7 @@ internal class BrandIdentifyFromTransactionResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandIdentifyFromTransactionResponse.Brand.Logo.builder() @@ -64,18 +64,20 @@ internal class BrandIdentifyFromTransactionResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandIdentifyFromTransactionResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandIdentifyFromTransactionResponse.Brand.Logo.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandIdentifyFromTransactionResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandIdentifyFromTransactionResponse.Brand.Social.builder() @@ -121,6 +123,7 @@ internal class BrandIdentifyFromTransactionResponseTest { .resolution( BrandIdentifyFromTransactionResponse.Brand.Backdrop.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -136,6 +139,7 @@ internal class BrandIdentifyFromTransactionResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandIdentifyFromTransactionResponse.Brand.Logo.builder() @@ -145,17 +149,19 @@ internal class BrandIdentifyFromTransactionResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandIdentifyFromTransactionResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandIdentifyFromTransactionResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandIdentifyFromTransactionResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandIdentifyFromTransactionResponse.Brand.Social.builder() @@ -176,7 +182,6 @@ internal class BrandIdentifyFromTransactionResponseTest { assertThat(brandIdentifyFromTransactionResponse.status()).contains("status") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() @@ -207,6 +212,7 @@ internal class BrandIdentifyFromTransactionResponseTest { .resolution( BrandIdentifyFromTransactionResponse.Brand.Backdrop.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -222,6 +228,7 @@ internal class BrandIdentifyFromTransactionResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandIdentifyFromTransactionResponse.Brand.Logo.builder() @@ -231,18 +238,20 @@ internal class BrandIdentifyFromTransactionResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandIdentifyFromTransactionResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandIdentifyFromTransactionResponse.Brand.Logo.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandIdentifyFromTransactionResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandIdentifyFromTransactionResponse.Brand.Social.builder() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt index a6162b8..b2ef496 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt @@ -3,18 +3,15 @@ package com.branddev.api.models.brand import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandPrefetchParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandPrefetchParams.builder().domain("domain").timeoutMs(1L).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun body() { val params = BrandPrefetchParams.builder().domain("domain").timeoutMs(1L).build() @@ -25,7 +22,6 @@ internal class BrandPrefetchParamsTest { assertThat(body.timeoutMs()).contains(1L) } - @Disabled("skipped: tests are disabled for the time being") @Test fun bodyWithoutOptionalFields() { val params = BrandPrefetchParams.builder().domain("domain").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchResponseTest.kt index e5eb558..e3204b5 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandPrefetchResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandPrefetchResponse = @@ -25,7 +23,6 @@ internal class BrandPrefetchResponseTest { assertThat(brandPrefetchResponse.status()).contains("status") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt index 8474257..006a17c 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt @@ -4,18 +4,15 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveByTickerParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandRetrieveByTickerParams.builder().ticker("ticker").timeoutMs(1L).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BrandRetrieveByTickerParams.builder().ticker("ticker").timeoutMs(1L).build() @@ -26,7 +23,6 @@ internal class BrandRetrieveByTickerParamsTest { .isEqualTo(QueryParams.builder().put("ticker", "ticker").put("timeoutMS", "1").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BrandRetrieveByTickerParams.builder().ticker("ticker").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt index c1b2408..fdbec1f 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveByTickerResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandRetrieveByTickerResponse = @@ -39,6 +37,7 @@ internal class BrandRetrieveByTickerResponseTest { .resolution( BrandRetrieveByTickerResponse.Brand.Backdrop.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -54,6 +53,7 @@ internal class BrandRetrieveByTickerResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandRetrieveByTickerResponse.Brand.Logo.builder() @@ -63,17 +63,19 @@ internal class BrandRetrieveByTickerResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveByTickerResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveByTickerResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandRetrieveByTickerResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandRetrieveByTickerResponse.Brand.Social.builder() @@ -118,6 +120,7 @@ internal class BrandRetrieveByTickerResponseTest { ) .resolution( BrandRetrieveByTickerResponse.Brand.Backdrop.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -133,6 +136,7 @@ internal class BrandRetrieveByTickerResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandRetrieveByTickerResponse.Brand.Logo.builder() @@ -142,17 +146,19 @@ internal class BrandRetrieveByTickerResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveByTickerResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveByTickerResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandRetrieveByTickerResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandRetrieveByTickerResponse.Brand.Social.builder() @@ -173,7 +179,6 @@ internal class BrandRetrieveByTickerResponseTest { assertThat(brandRetrieveByTickerResponse.status()).contains("status") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() @@ -203,6 +208,7 @@ internal class BrandRetrieveByTickerResponseTest { .resolution( BrandRetrieveByTickerResponse.Brand.Backdrop.Resolution .builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -218,6 +224,7 @@ internal class BrandRetrieveByTickerResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandRetrieveByTickerResponse.Brand.Logo.builder() @@ -227,17 +234,19 @@ internal class BrandRetrieveByTickerResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveByTickerResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveByTickerResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandRetrieveByTickerResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandRetrieveByTickerResponse.Brand.Social.builder() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt index f1de4cf..711682f 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt @@ -4,18 +4,15 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveNaicsParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandRetrieveNaicsParams.builder().input("input").timeoutMs(1L).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BrandRetrieveNaicsParams.builder().input("input").timeoutMs(1L).build() @@ -26,7 +23,6 @@ internal class BrandRetrieveNaicsParamsTest { .isEqualTo(QueryParams.builder().put("input", "input").put("timeoutMS", "1").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BrandRetrieveNaicsParams.builder().input("input").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsResponseTest.kt index fb668ab..e8163b6 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsResponseTest.kt @@ -6,12 +6,10 @@ import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveNaicsResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandRetrieveNaicsResponse = @@ -33,7 +31,6 @@ internal class BrandRetrieveNaicsResponseTest { assertThat(brandRetrieveNaicsResponse.type()).contains("type") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt index 2b2d5df..5f9b0b2 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt @@ -4,12 +4,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandRetrieveParams.builder() @@ -20,7 +18,6 @@ internal class BrandRetrieveParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -44,7 +41,6 @@ internal class BrandRetrieveParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BrandRetrieveParams.builder().domain("domain").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt index fb73c89..2d49ebe 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandRetrieveResponse = @@ -38,6 +36,7 @@ internal class BrandRetrieveResponseTest { ) .resolution( BrandRetrieveResponse.Brand.Backdrop.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -53,6 +52,7 @@ internal class BrandRetrieveResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandRetrieveResponse.Brand.Logo.builder() @@ -62,17 +62,19 @@ internal class BrandRetrieveResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandRetrieveResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandRetrieveResponse.Brand.Social.builder() @@ -117,6 +119,7 @@ internal class BrandRetrieveResponseTest { ) .resolution( BrandRetrieveResponse.Brand.Backdrop.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -129,6 +132,7 @@ internal class BrandRetrieveResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandRetrieveResponse.Brand.Logo.builder() @@ -138,17 +142,19 @@ internal class BrandRetrieveResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandRetrieveResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandRetrieveResponse.Brand.Social.builder().type("type").url("url").build() @@ -166,7 +172,6 @@ internal class BrandRetrieveResponseTest { assertThat(brandRetrieveResponse.status()).contains("status") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() @@ -195,6 +200,7 @@ internal class BrandRetrieveResponseTest { ) .resolution( BrandRetrieveResponse.Brand.Backdrop.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() @@ -210,6 +216,7 @@ internal class BrandRetrieveResponseTest { ) .description("description") .domain("domain") + .email("email") .isNsfw(true) .addLogo( BrandRetrieveResponse.Brand.Logo.builder() @@ -219,17 +226,19 @@ internal class BrandRetrieveResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) .height(0L) .width(0L) .build() ) + .type(BrandRetrieveResponse.Brand.Logo.Type.ICON) .url("url") .build() ) + .phone("phone") .slogan("slogan") .addSocial( BrandRetrieveResponse.Brand.Social.builder() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParamsTest.kt index c3a3e1e..07f3ffa 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParamsTest.kt @@ -4,18 +4,15 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveSimplifiedParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandRetrieveSimplifiedParams.builder().domain("domain").timeoutMs(1L).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BrandRetrieveSimplifiedParams.builder().domain("domain").timeoutMs(1L).build() @@ -26,7 +23,6 @@ internal class BrandRetrieveSimplifiedParamsTest { .isEqualTo(QueryParams.builder().put("domain", "domain").put("timeoutMS", "1").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BrandRetrieveSimplifiedParams.builder().domain("domain").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponseTest.kt index 7479ae5..c4dd272 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandRetrieveSimplifiedResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandRetrieveSimplifiedResponse = @@ -51,8 +49,7 @@ internal class BrandRetrieveSimplifiedResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveSimplifiedResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveSimplifiedResponse.Brand.Logo.Resolution.builder() .aspectRatio(0.0) @@ -60,7 +57,7 @@ internal class BrandRetrieveSimplifiedResponseTest { .width(0L) .build() ) - .type("type") + .type(BrandRetrieveSimplifiedResponse.Brand.Logo.Type.ICON) .url("url") .build() ) @@ -107,8 +104,7 @@ internal class BrandRetrieveSimplifiedResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveSimplifiedResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveSimplifiedResponse.Brand.Logo.Resolution.builder() .aspectRatio(0.0) @@ -116,7 +112,7 @@ internal class BrandRetrieveSimplifiedResponseTest { .width(0L) .build() ) - .type("type") + .type(BrandRetrieveSimplifiedResponse.Brand.Logo.Type.ICON) .url("url") .build() ) @@ -127,7 +123,6 @@ internal class BrandRetrieveSimplifiedResponseTest { assertThat(brandRetrieveSimplifiedResponse.status()).contains("status") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() @@ -169,8 +164,7 @@ internal class BrandRetrieveSimplifiedResponseTest { .name("name") .build() ) - .group(0L) - .mode("mode") + .mode(BrandRetrieveSimplifiedResponse.Brand.Logo.Mode.LIGHT) .resolution( BrandRetrieveSimplifiedResponse.Brand.Logo.Resolution.builder() .aspectRatio(0.0) @@ -178,7 +172,7 @@ internal class BrandRetrieveSimplifiedResponseTest { .width(0L) .build() ) - .type("type") + .type(BrandRetrieveSimplifiedResponse.Brand.Logo.Type.ICON) .url("url") .build() ) diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotParamsTest.kt index e97bd10..e1542ab 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotParamsTest.kt @@ -4,12 +4,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandScreenshotParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandScreenshotParams.builder() @@ -18,7 +16,6 @@ internal class BrandScreenshotParamsTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = @@ -35,7 +32,6 @@ internal class BrandScreenshotParamsTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BrandScreenshotParams.builder().domain("domain").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotResponseTest.kt index f79b8de..bdddd57 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandScreenshotResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandScreenshotResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandScreenshotResponse = @@ -30,7 +28,6 @@ internal class BrandScreenshotResponseTest { assertThat(brandScreenshotResponse.status()).contains("status") } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideParamsTest.kt index c8476df..c5f8543 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideParamsTest.kt @@ -4,18 +4,15 @@ package com.branddev.api.models.brand import com.branddev.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandStyleguideParamsTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { BrandStyleguideParams.builder().domain("domain").timeoutMs(1L).build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { val params = BrandStyleguideParams.builder().domain("domain").timeoutMs(1L).build() @@ -26,7 +23,6 @@ internal class BrandStyleguideParamsTest { .isEqualTo(QueryParams.builder().put("domain", "domain").put("timeoutMS", "1").build()) } - @Disabled("skipped: tests are disabled for the time being") @Test fun queryParamsWithoutOptionalFields() { val params = BrandStyleguideParams.builder().domain("domain").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideResponseTest.kt index d2f4ec0..78b6dda 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandStyleguideResponseTest.kt @@ -5,12 +5,10 @@ package com.branddev.api.models.brand import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class BrandStyleguideResponseTest { - @Disabled("skipped: tests are disabled for the time being") @Test fun create() { val brandStyleguideResponse = @@ -342,7 +340,6 @@ internal class BrandStyleguideResponseTest { ) } - @Disabled("skipped: tests are disabled for the time being") @Test fun roundtrip() { val jsonMapper = jsonMapper() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt index 0d4b258..5b14671 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt @@ -26,7 +26,6 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.parallel.ResourceLock @@ -59,7 +58,6 @@ internal class ErrorHandlingTest { .build() } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve400() { val brandService = client.brand() @@ -87,7 +85,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve400WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -115,7 +112,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve401() { val brandService = client.brand() @@ -143,7 +139,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve401WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -171,7 +166,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve403() { val brandService = client.brand() @@ -199,7 +193,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve403WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -227,7 +220,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve404() { val brandService = client.brand() @@ -255,7 +247,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve404WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -283,7 +274,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve422() { val brandService = client.brand() @@ -311,7 +301,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve422WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -339,7 +328,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve429() { val brandService = client.brand() @@ -367,7 +355,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve429WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -395,7 +382,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve500() { val brandService = client.brand() @@ -423,7 +409,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve500WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -451,7 +436,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve999() { val brandService = client.brand() @@ -479,7 +463,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve999WithRawResponse() { val brandService = client.brand().withRawResponse() @@ -507,7 +490,6 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } - @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieveInvalidJsonBody() { val brandService = client.brand() diff --git a/brand-dev-java-proguard-test/build.gradle.kts b/brand-dev-java-proguard-test/build.gradle.kts new file mode 100644 index 0000000..901fb98 --- /dev/null +++ b/brand-dev-java-proguard-test/build.gradle.kts @@ -0,0 +1,74 @@ +plugins { + id("brand-dev.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + } +} + +dependencies { + testImplementation(project(":brand-dev-java")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + testImplementation("org.junit.platform:junit-platform-console:1.10.1") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + verbose() + dontwarn() + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../brand-dev-java-core/src/main/resources/META-INF/proguard/brand-dev-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("org.junit.platform.console.ConsoleLauncher") + classpath = files(proguardJarPath) + args = listOf( + "--classpath", proguardJarPath, + "--scan-classpath", + "--details", "verbose", + ) +} + +tasks.test { + dependsOn(testProGuard) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/brand-dev-java-proguard-test/src/test/kotlin/com/branddev/api/proguard/ProGuardCompatibilityTest.kt b/brand-dev-java-proguard-test/src/test/kotlin/com/branddev/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 0000000..702b584 --- /dev/null +++ b/brand-dev-java-proguard-test/src/test/kotlin/com/branddev/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.proguard + +import com.branddev.api.client.okhttp.BrandDevOkHttpClient +import com.branddev.api.core.jsonMapper +import com.branddev.api.models.brand.BrandRetrieveResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @BeforeAll + @JvmStatic + fun setUp() { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream("META-INF/proguard/brand-dev-java-core.pro") + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = BrandDevOkHttpClient.builder().apiKey("My API Key").build() + + assertThat(client).isNotNull() + assertThat(client.brand()).isNotNull() + } + + @Test + fun brandRetrieveResponseRoundtrip() { + val jsonMapper = jsonMapper() + val brandRetrieveResponse = + BrandRetrieveResponse.builder() + .brand( + BrandRetrieveResponse.Brand.builder() + .address( + BrandRetrieveResponse.Brand.Address.builder() + .city("city") + .country("country") + .countryCode("country_code") + .postalCode("postal_code") + .stateCode("state_code") + .stateProvince("state_province") + .street("street") + .build() + ) + .addBackdrop( + BrandRetrieveResponse.Brand.Backdrop.builder() + .addColor( + BrandRetrieveResponse.Brand.Backdrop.Color.builder() + .hex("hex") + .name("name") + .build() + ) + .resolution( + BrandRetrieveResponse.Brand.Backdrop.Resolution.builder() + .aspectRatio(0.0) + .height(0L) + .width(0L) + .build() + ) + .url("url") + .build() + ) + .addColor( + BrandRetrieveResponse.Brand.Color.builder() + .hex("hex") + .name("name") + .build() + ) + .description("description") + .domain("domain") + .email("email") + .isNsfw(true) + .addLogo( + BrandRetrieveResponse.Brand.Logo.builder() + .addColor( + BrandRetrieveResponse.Brand.Logo.Color.builder() + .hex("hex") + .name("name") + .build() + ) + .mode(BrandRetrieveResponse.Brand.Logo.Mode.LIGHT) + .resolution( + BrandRetrieveResponse.Brand.Logo.Resolution.builder() + .aspectRatio(0.0) + .height(0L) + .width(0L) + .build() + ) + .type(BrandRetrieveResponse.Brand.Logo.Type.ICON) + .url("url") + .build() + ) + .phone("phone") + .slogan("slogan") + .addSocial( + BrandRetrieveResponse.Brand.Social.builder() + .type("type") + .url("url") + .build() + ) + .stock( + BrandRetrieveResponse.Brand.Stock.builder() + .exchange("exchange") + .ticker("ticker") + .build() + ) + .title("title") + .build() + ) + .code(0L) + .status("status") + .build() + + val roundtrippedBrandRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(brandRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrandRetrieveResponse).isEqualTo(brandRetrieveResponse) + } +} diff --git a/brand-dev-java-proguard-test/test.pro b/brand-dev-java-proguard-test/test.pro new file mode 100644 index 0000000..e9a70ba --- /dev/null +++ b/brand-dev-java-proguard-test/test.pro @@ -0,0 +1,5 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class com.branddev.api.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 7bf7bfc..88ca196 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,4 +3,5 @@ rootProject.name = "brand-dev-java-root" include("brand-dev-java") include("brand-dev-java-client-okhttp") include("brand-dev-java-core") +include("brand-dev-java-proguard-test") include("brand-dev-java-example")