diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc563e0..3aac699 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,10 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: diff --git a/.release-please-manifest.json b/.release-please-manifest.json index aaf968a..b56c3d0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.3" + ".": "0.1.0-alpha.4" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index e5a78c5..f0d7da7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 7 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-103a28182099d9866bc8c40db00f3356fe5be36302874e7ee84ee4fd2f593859.yml -openapi_spec_hash: 30241efa79f9aab6e430c29383d9a2cf -config_hash: 4ab8d35881cc0191126ff443317e03ba +configured_endpoints: 10 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-3f6d4c0f819a0d3128951d315ad216df22050fbc47c5f601d261d56f8b1d80a5.yml +openapi_spec_hash: 8e7953259a1b6bd7440a780eccad1742 +config_hash: 8f3ee44d690a305369555016a77ed016 diff --git a/CHANGELOG.md b/CHANGELOG.md index 131d2cf..f208513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.1.0-alpha.4 (2025-06-19) + +Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.3...v0.1.0-alpha.4) + +### Features + +* **api:** manual updates ([5d445e8](https://github.com/brand-dot-dev/java-sdk/commit/5d445e85b7a5c05acbdcebaf4f3e2e7ed5c9f909)) +* **api:** manual updates ([8b819ae](https://github.com/brand-dot-dev/java-sdk/commit/8b819ae77d457e0d8cd987f3e83c8070e25e2c13)) + + +### Chores + +* **ci:** enable for pull requests ([393159f](https://github.com/brand-dot-dev/java-sdk/commit/393159f9bc12a5bb89dd42305ab6601f781a2c29)) + ## 0.1.0-alpha.3 (2025-06-13) Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) diff --git a/README.md b/README.md index b39c707..8d0e28b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.3) -[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.3/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.3) +[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.4) +[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.4/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.4) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.3). +Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.4). @@ -24,7 +24,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/b ### Gradle ```kotlin -implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.3") +implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.4") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.3") com.branddev.api brand-dev-java - 0.1.0-alpha.3 + 0.1.0-alpha.4 ``` 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 new file mode 100644 index 0000000..bd09908 --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.models.brand + +import com.branddev.api.core.Params +import com.branddev.api.core.checkRequired +import com.branddev.api.core.http.Headers +import com.branddev.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns a simplified version of brand data containing only essential information: domain, title, + * colors, logos, and backdrops. This endpoint is optimized for faster responses and reduced data + * transfer. + */ +class BrandRetrieveSimplifiedParams +private constructor( + private val domain: String, + private val timeoutMs: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Domain name to retrieve simplified brand data for */ + fun domain(): String = domain + + /** + * Optional timeout in milliseconds for the request. If the request takes longer than this + * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 + * minutes). + */ + fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BrandRetrieveSimplifiedParams]. + * + * The following fields are required: + * ```java + * .domain() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandRetrieveSimplifiedParams]. */ + class Builder internal constructor() { + + private var domain: String? = null + private var timeoutMs: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandRetrieveSimplifiedParams: BrandRetrieveSimplifiedParams) = apply { + domain = brandRetrieveSimplifiedParams.domain + timeoutMs = brandRetrieveSimplifiedParams.timeoutMs + additionalHeaders = brandRetrieveSimplifiedParams.additionalHeaders.toBuilder() + additionalQueryParams = brandRetrieveSimplifiedParams.additionalQueryParams.toBuilder() + } + + /** Domain name to retrieve simplified brand data for */ + fun domain(domain: String) = apply { this.domain = domain } + + /** + * Optional timeout in milliseconds for the request. If the request takes longer than this + * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 + * minutes). + */ + fun timeoutMs(timeoutMs: Long?) = apply { this.timeoutMs = timeoutMs } + + /** + * Alias for [Builder.timeoutMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun timeoutMs(timeoutMs: Long) = timeoutMs(timeoutMs as Long?) + + /** Alias for calling [Builder.timeoutMs] with `timeoutMs.orElse(null)`. */ + fun timeoutMs(timeoutMs: Optional) = timeoutMs(timeoutMs.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandRetrieveSimplifiedParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .domain() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandRetrieveSimplifiedParams = + BrandRetrieveSimplifiedParams( + checkRequired("domain", domain), + timeoutMs, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("domain", domain) + timeoutMs?.let { put("timeoutMS", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BrandRetrieveSimplifiedParams && domain == other.domain && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(domain, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "BrandRetrieveSimplifiedParams{domain=$domain, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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 new file mode 100644 index 0000000..9ca3a72 --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveSimplifiedResponse.kt @@ -0,0 +1,2130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.models.brand + +import com.branddev.api.core.ExcludeMissing +import com.branddev.api.core.JsonField +import com.branddev.api.core.JsonMissing +import com.branddev.api.core.JsonValue +import com.branddev.api.core.checkKnown +import com.branddev.api.core.toImmutable +import com.branddev.api.errors.BrandDevInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BrandRetrieveSimplifiedResponse +private constructor( + private val brand: JsonField, + private val code: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(brand, code, status, mutableMapOf()) + + /** + * Simplified brand information + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brand(): Optional = brand.getOptional("brand") + + /** + * HTTP status code of the response + * + * @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") + + /** + * Status of the response, e.g., 'ok' + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand + + /** + * 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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BrandRetrieveSimplifiedResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandRetrieveSimplifiedResponse]. */ + class Builder internal constructor() { + + private var brand: JsonField = JsonMissing.of() + private var code: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandRetrieveSimplifiedResponse: BrandRetrieveSimplifiedResponse) = + apply { + brand = brandRetrieveSimplifiedResponse.brand + code = brandRetrieveSimplifiedResponse.code + status = brandRetrieveSimplifiedResponse.status + additionalProperties = + brandRetrieveSimplifiedResponse.additionalProperties.toMutableMap() + } + + /** Simplified brand information */ + fun brand(brand: Brand) = brand(JsonField.of(brand)) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [Brand] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brand(brand: JsonField) = apply { this.brand = brand } + + /** HTTP status code of the response */ + 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 } + + /** Status of the response, e.g., 'ok' */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandRetrieveSimplifiedResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandRetrieveSimplifiedResponse = + BrandRetrieveSimplifiedResponse( + brand, + code, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrandRetrieveSimplifiedResponse = apply { + if (validated) { + return@apply + } + + brand().ifPresent { it.validate() } + code() + status() + 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 = + (brand.asKnown().getOrNull()?.validity() ?: 0) + + (if (code.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + /** Simplified brand information */ + class Brand + private constructor( + private val backdrops: JsonField>, + private val colors: JsonField>, + private val domain: JsonField, + private val logos: JsonField>, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("backdrops") + @ExcludeMissing + backdrops: JsonField> = JsonMissing.of(), + @JsonProperty("colors") + @ExcludeMissing + colors: JsonField> = JsonMissing.of(), + @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(backdrops, colors, domain, logos, title, mutableMapOf()) + + /** + * An array of backdrop images for the brand + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun backdrops(): Optional> = backdrops.getOptional("backdrops") + + /** + * An array of brand colors + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun colors(): Optional> = colors.getOptional("colors") + + /** + * The domain name of the brand + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun domain(): Optional = domain.getOptional("domain") + + /** + * An array of logos associated with the brand + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun logos(): Optional> = logos.getOptional("logos") + + /** + * The title or name of the brand + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("title") + + /** + * Returns the raw JSON value of [backdrops]. + * + * Unlike [backdrops], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("backdrops") + @ExcludeMissing + fun _backdrops(): JsonField> = backdrops + + /** + * Returns the raw JSON value of [colors]. + * + * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField> = colors + + /** + * Returns the raw JSON value of [domain]. + * + * Unlike [domain], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + + /** + * Returns the raw JSON value of [logos]. + * + * Unlike [logos], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logos") @ExcludeMissing fun _logos(): JsonField> = logos + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Brand]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Brand]. */ + class Builder internal constructor() { + + private var backdrops: JsonField>? = null + private var colors: JsonField>? = null + private var domain: JsonField = JsonMissing.of() + private var logos: JsonField>? = null + private var title: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brand: Brand) = apply { + backdrops = brand.backdrops.map { it.toMutableList() } + colors = brand.colors.map { it.toMutableList() } + domain = brand.domain + logos = brand.logos.map { it.toMutableList() } + title = brand.title + additionalProperties = brand.additionalProperties.toMutableMap() + } + + /** An array of backdrop images for the brand */ + fun backdrops(backdrops: List) = backdrops(JsonField.of(backdrops)) + + /** + * Sets [Builder.backdrops] to an arbitrary JSON value. + * + * You should usually call [Builder.backdrops] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun backdrops(backdrops: JsonField>) = apply { + this.backdrops = backdrops.map { it.toMutableList() } + } + + /** + * Adds a single [Backdrop] to [backdrops]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBackdrop(backdrop: Backdrop) = apply { + backdrops = + (backdrops ?: JsonField.of(mutableListOf())).also { + checkKnown("backdrops", it).add(backdrop) + } + } + + /** An array of brand colors */ + fun colors(colors: List) = colors(JsonField.of(colors)) + + /** + * Sets [Builder.colors] to an arbitrary JSON value. + * + * You should usually call [Builder.colors] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun colors(colors: JsonField>) = apply { + this.colors = colors.map { it.toMutableList() } + } + + /** + * Adds a single [Color] to [colors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColor(color: Color) = apply { + colors = + (colors ?: JsonField.of(mutableListOf())).also { + checkKnown("colors", it).add(color) + } + } + + /** The domain name of the brand */ + fun domain(domain: String) = domain(JsonField.of(domain)) + + /** + * Sets [Builder.domain] to an arbitrary JSON value. + * + * You should usually call [Builder.domain] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun domain(domain: JsonField) = apply { this.domain = domain } + + /** An array of logos associated with the brand */ + fun logos(logos: List) = logos(JsonField.of(logos)) + + /** + * Sets [Builder.logos] to an arbitrary JSON value. + * + * You should usually call [Builder.logos] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun logos(logos: JsonField>) = apply { + this.logos = logos.map { it.toMutableList() } + } + + /** + * Adds a single [Logo] to [logos]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLogo(logo: Logo) = apply { + logos = + (logos ?: JsonField.of(mutableListOf())).also { + checkKnown("logos", it).add(logo) + } + } + + /** The title or name of the brand */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Brand]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Brand = + Brand( + (backdrops ?: JsonMissing.of()).map { it.toImmutable() }, + (colors ?: JsonMissing.of()).map { it.toImmutable() }, + domain, + (logos ?: JsonMissing.of()).map { it.toImmutable() }, + title, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Brand = apply { + if (validated) { + return@apply + } + + backdrops().ifPresent { it.forEach { it.validate() } } + colors().ifPresent { it.forEach { it.validate() } } + domain() + logos().ifPresent { it.forEach { it.validate() } } + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: BrandDevInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (backdrops.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (domain.asKnown().isPresent) 1 else 0) + + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + class Backdrop + private constructor( + private val colors: JsonField>, + private val resolution: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("colors") + @ExcludeMissing + colors: JsonField> = JsonMissing.of(), + @JsonProperty("resolution") + @ExcludeMissing + resolution: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(colors, resolution, url, mutableMapOf()) + + /** + * Array of colors in the backdrop image + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun colors(): Optional> = colors.getOptional("colors") + + /** + * Resolution of the backdrop image + * + * @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") + + /** + * URL of the backdrop image + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [colors]. + * + * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField> = colors + + /** + * Returns the raw JSON value of [resolution]. + * + * Unlike [resolution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resolution") + @ExcludeMissing + fun _resolution(): JsonField = resolution + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Backdrop]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Backdrop]. */ + class Builder internal constructor() { + + private var colors: JsonField>? = null + private var resolution: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(backdrop: Backdrop) = apply { + colors = backdrop.colors.map { it.toMutableList() } + resolution = backdrop.resolution + url = backdrop.url + additionalProperties = backdrop.additionalProperties.toMutableMap() + } + + /** Array of colors in the backdrop image */ + fun colors(colors: List) = colors(JsonField.of(colors)) + + /** + * Sets [Builder.colors] to an arbitrary JSON value. + * + * You should usually call [Builder.colors] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun colors(colors: JsonField>) = apply { + this.colors = colors.map { it.toMutableList() } + } + + /** + * Adds a single [Color] to [colors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColor(color: Color) = apply { + colors = + (colors ?: JsonField.of(mutableListOf())).also { + checkKnown("colors", it).add(color) + } + } + + /** Resolution of the backdrop image */ + fun resolution(resolution: Resolution) = resolution(JsonField.of(resolution)) + + /** + * Sets [Builder.resolution] to an arbitrary JSON value. + * + * You should usually call [Builder.resolution] with a well-typed [Resolution] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun resolution(resolution: JsonField) = apply { + this.resolution = resolution + } + + /** URL of the backdrop image */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Backdrop]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Backdrop = + Backdrop( + (colors ?: JsonMissing.of()).map { it.toImmutable() }, + resolution, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Backdrop = apply { + if (validated) { + return@apply + } + + colors().ifPresent { it.forEach { it.validate() } } + resolution().ifPresent { it.validate() } + url() + 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 = + (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (resolution.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + class Color + private constructor( + private val hex: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("hex") @ExcludeMissing hex: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(hex, name, mutableMapOf()) + + /** + * Color in hexadecimal format + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hex(): Optional = hex.getOptional("hex") + + /** + * Name of the color + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [hex]. + * + * Unlike [hex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hex") @ExcludeMissing fun _hex(): JsonField = hex + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Color]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Color]. */ + class Builder internal constructor() { + + private var hex: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(color: Color) = apply { + hex = color.hex + name = color.name + additionalProperties = color.additionalProperties.toMutableMap() + } + + /** Color in hexadecimal format */ + fun hex(hex: String) = hex(JsonField.of(hex)) + + /** + * Sets [Builder.hex] to an arbitrary JSON value. + * + * You should usually call [Builder.hex] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun hex(hex: JsonField) = apply { this.hex = hex } + + /** Name of the color */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Color]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Color = Color(hex, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Color = apply { + if (validated) { + return@apply + } + + hex() + name() + 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 (hex.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Color && hex == other.hex && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(hex, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" + } + + /** 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, + ) { + + @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(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 + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Width of the image in pixels + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + 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]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Resolution]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Width of the image in pixels */ + fun width(width: Long) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Resolution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Resolution = + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Resolution = apply { + if (validated) { + return@apply + } + + aspectRatio() + height() + width() + 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 (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 { + if (this === other) { + return true + } + + 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(aspectRatio, height, width, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Backdrop && colors == other.colors && resolution == other.resolution && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(colors, resolution, url, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Backdrop{colors=$colors, resolution=$resolution, url=$url, additionalProperties=$additionalProperties}" + } + + class Color + private constructor( + private val hex: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("hex") @ExcludeMissing hex: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(hex, name, mutableMapOf()) + + /** + * Color in hexadecimal format + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun hex(): Optional = hex.getOptional("hex") + + /** + * Name of the color + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [hex]. + * + * Unlike [hex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hex") @ExcludeMissing fun _hex(): JsonField = hex + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Color]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Color]. */ + class Builder internal constructor() { + + private var hex: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(color: Color) = apply { + hex = color.hex + name = color.name + additionalProperties = color.additionalProperties.toMutableMap() + } + + /** Color in hexadecimal format */ + fun hex(hex: String) = hex(JsonField.of(hex)) + + /** + * Sets [Builder.hex] to an arbitrary JSON value. + * + * You should usually call [Builder.hex] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hex(hex: JsonField) = apply { this.hex = hex } + + /** Name of the color */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Color]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Color = Color(hex, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Color = apply { + if (validated) { + return@apply + } + + hex() + name() + 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 (hex.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Color && hex == other.hex && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(hex, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" + } + + class Logo + private constructor( + private val colors: JsonField>, + private val group: JsonField, + private val mode: JsonField, + private val resolution: JsonField, + private val type: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("colors") + @ExcludeMissing + colors: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: 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, type, url, mutableMapOf()) + + /** + * Array of colors in the logo + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun colors(): Optional> = colors.getOptional("colors") + + /** + * Group identifier for logos + * + * @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") + + /** + * 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 resolution(): Optional = resolution.getOptional("resolution") + + /** + * Type of the logo based on resolution (e.g., 'icon', 'logo', 'banner') + * + * @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") + + /** + * URL 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 url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [colors]. + * + * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. + */ + @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 + + /** + * Returns the raw JSON value of [resolution]. + * + * Unlike [resolution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resolution") + @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]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Logo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Logo]. */ + class Builder internal constructor() { + + private var colors: JsonField>? = null + private var group: 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() + } + + /** Array of colors in the logo */ + fun colors(colors: List) = colors(JsonField.of(colors)) + + /** + * Sets [Builder.colors] to an arbitrary JSON value. + * + * You should usually call [Builder.colors] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun colors(colors: JsonField>) = apply { + this.colors = colors.map { it.toMutableList() } + } + + /** + * Adds a single [Color] to [colors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColor(color: Color) = apply { + colors = + (colors ?: JsonField.of(mutableListOf())).also { + checkKnown("colors", it).add(color) + } + } + + /** 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. + */ + fun group(group: JsonField) = apply { this.group = group } + + /** Mode of the logo, e.g., 'dark', 'light' */ + fun mode(mode: String) = 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. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + /** Resolution of the logo image */ + fun resolution(resolution: Resolution) = resolution(JsonField.of(resolution)) + + /** + * Sets [Builder.resolution] to an arbitrary JSON value. + * + * You should usually call [Builder.resolution] with a well-typed [Resolution] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun resolution(resolution: JsonField) = apply { + this.resolution = resolution + } + + /** Type of the logo based on resolution (e.g., 'icon', 'logo', 'banner') */ + fun type(type: String) = 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. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** URL of the logo image */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Logo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Logo = + Logo( + (colors ?: JsonMissing.of()).map { it.toImmutable() }, + group, + mode, + resolution, + type, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Logo = apply { + if (validated) { + return@apply + } + + colors().ifPresent { it.forEach { it.validate() } } + group() + mode() + resolution().ifPresent { it.validate() } + type() + url() + 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 = + (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) + + (if (mode.asKnown().isPresent) 1 else 0) + + (resolution.asKnown().getOrNull()?.validity() ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + class Color + private constructor( + private val hex: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("hex") @ExcludeMissing hex: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(hex, name, mutableMapOf()) + + /** + * Color in hexadecimal format + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hex(): Optional = hex.getOptional("hex") + + /** + * Name of the color + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [hex]. + * + * Unlike [hex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hex") @ExcludeMissing fun _hex(): JsonField = hex + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Color]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Color]. */ + class Builder internal constructor() { + + private var hex: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(color: Color) = apply { + hex = color.hex + name = color.name + additionalProperties = color.additionalProperties.toMutableMap() + } + + /** Color in hexadecimal format */ + fun hex(hex: String) = hex(JsonField.of(hex)) + + /** + * Sets [Builder.hex] to an arbitrary JSON value. + * + * You should usually call [Builder.hex] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun hex(hex: JsonField) = apply { this.hex = hex } + + /** Name of the color */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Color]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Color = Color(hex, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Color = apply { + if (validated) { + return@apply + } + + hex() + name() + 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 (hex.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Color && hex == other.hex && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(hex, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" + } + + /** 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, + ) { + + @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(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 + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Width of the image in pixels + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + 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]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Resolution]. */ + @JvmStatic fun builder() = Builder() + } + + /** 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)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Width of the image in pixels */ + fun width(width: Long) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Resolution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Resolution = + Resolution(aspectRatio, height, width, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Resolution = apply { + if (validated) { + return@apply + } + + aspectRatio() + height() + width() + 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 (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 { + if (this === other) { + return true + } + + 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(aspectRatio, height, width, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Resolution{aspectRatio=$aspectRatio, height=$height, width=$width, additionalProperties=$additionalProperties}" + } + + 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 */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(colors, group, 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}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Brand && backdrops == other.backdrops && colors == other.colors && domain == other.domain && logos == other.logos && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(backdrops, colors, domain, logos, title, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Brand{backdrops=$backdrops, colors=$colors, domain=$domain, logos=$logos, title=$title, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BrandRetrieveSimplifiedResponse && brand == other.brand && code == other.code && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(brand, code, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandRetrieveSimplifiedResponse{brand=$brand, code=$code, status=$status, additionalProperties=$additionalProperties}" +} 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 new file mode 100644 index 0000000..0fa8913 --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotParams.kt @@ -0,0 +1,374 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.models.brand + +import com.branddev.api.core.Enum +import com.branddev.api.core.JsonField +import com.branddev.api.core.Params +import com.branddev.api.core.checkRequired +import com.branddev.api.core.http.Headers +import com.branddev.api.core.http.QueryParams +import com.branddev.api.errors.BrandDevInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Beta feature: Capture a screenshot of a website. Supports both viewport (standard browser view) + * and full-page screenshots. Returns a URL to the uploaded screenshot image hosted on our CDN. + */ +class BrandScreenshotParams +private constructor( + private val domain: String, + private val fullScreenshot: FullScreenshot?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domain will be + * automatically normalized and validated. + */ + fun domain(): String = domain + + /** + * Optional parameter to determine screenshot type. If 'true', takes a full page screenshot + * capturing all content. If 'false' or not provided, takes a viewport screenshot (standard + * browser view). + */ + fun fullScreenshot(): Optional = Optional.ofNullable(fullScreenshot) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandScreenshotParams]. + * + * The following fields are required: + * ```java + * .domain() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandScreenshotParams]. */ + class Builder internal constructor() { + + private var domain: String? = null + private var fullScreenshot: FullScreenshot? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandScreenshotParams: BrandScreenshotParams) = apply { + domain = brandScreenshotParams.domain + fullScreenshot = brandScreenshotParams.fullScreenshot + additionalHeaders = brandScreenshotParams.additionalHeaders.toBuilder() + additionalQueryParams = brandScreenshotParams.additionalQueryParams.toBuilder() + } + + /** + * Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domain will be + * automatically normalized and validated. + */ + fun domain(domain: String) = apply { this.domain = domain } + + /** + * Optional parameter to determine screenshot type. If 'true', takes a full page screenshot + * capturing all content. If 'false' or not provided, takes a viewport screenshot (standard + * browser view). + */ + fun fullScreenshot(fullScreenshot: FullScreenshot?) = apply { + this.fullScreenshot = fullScreenshot + } + + /** Alias for calling [Builder.fullScreenshot] with `fullScreenshot.orElse(null)`. */ + fun fullScreenshot(fullScreenshot: Optional) = + fullScreenshot(fullScreenshot.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandScreenshotParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .domain() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandScreenshotParams = + BrandScreenshotParams( + checkRequired("domain", domain), + fullScreenshot, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("domain", domain) + fullScreenshot?.let { put("fullScreenshot", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** + * Optional parameter to determine screenshot type. If 'true', takes a full page screenshot + * capturing all content. If 'false' or not provided, takes a viewport screenshot (standard + * browser view). + */ + class FullScreenshot @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 TRUE = of("true") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = FullScreenshot(JsonField.of(value)) + } + + /** An enum containing [FullScreenshot]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [FullScreenshot]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FullScreenshot] 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 { + TRUE, + FALSE, + /** + * An enum member indicating that [FullScreenshot] 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) { + TRUE -> Value.TRUE + FALSE -> Value.FALSE + 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) { + TRUE -> Known.TRUE + FALSE -> Known.FALSE + else -> throw BrandDevInvalidDataException("Unknown FullScreenshot: $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(): FullScreenshot = 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 FullScreenshot && 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 BrandScreenshotParams && domain == other.domain && fullScreenshot == other.fullScreenshot && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(domain, fullScreenshot, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "BrandScreenshotParams{domain=$domain, fullScreenshot=$fullScreenshot, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotResponse.kt new file mode 100644 index 0000000..b4fdbcd --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandScreenshotResponse.kt @@ -0,0 +1,437 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.branddev.api.core.JsonValue +import com.branddev.api.errors.BrandDevInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BrandScreenshotResponse +private constructor( + private val code: JsonField, + private val domain: JsonField, + private val screenshot: JsonField, + private val screenshotType: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("screenshot") + @ExcludeMissing + screenshot: JsonField = JsonMissing.of(), + @JsonProperty("screenshotType") + @ExcludeMissing + screenshotType: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(code, domain, screenshot, screenshotType, status, 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") + + /** + * The normalized domain that was processed + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun domain(): Optional = domain.getOptional("domain") + + /** + * Public URL of the uploaded screenshot image + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun screenshot(): Optional = screenshot.getOptional("screenshot") + + /** + * Type of screenshot that was captured + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun screenshotType(): Optional = screenshotType.getOptional("screenshotType") + + /** + * Status of the response, e.g., 'ok' + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * 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 [domain]. + * + * Unlike [domain], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + + /** + * Returns the raw JSON value of [screenshot]. + * + * Unlike [screenshot], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("screenshot") @ExcludeMissing fun _screenshot(): JsonField = screenshot + + /** + * Returns the raw JSON value of [screenshotType]. + * + * Unlike [screenshotType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("screenshotType") + @ExcludeMissing + fun _screenshotType(): JsonField = screenshotType + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BrandScreenshotResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandScreenshotResponse]. */ + class Builder internal constructor() { + + private var code: JsonField = JsonMissing.of() + private var domain: JsonField = JsonMissing.of() + private var screenshot: JsonField = JsonMissing.of() + private var screenshotType: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandScreenshotResponse: BrandScreenshotResponse) = apply { + code = brandScreenshotResponse.code + domain = brandScreenshotResponse.domain + screenshot = brandScreenshotResponse.screenshot + screenshotType = brandScreenshotResponse.screenshotType + status = brandScreenshotResponse.status + additionalProperties = brandScreenshotResponse.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 } + + /** The normalized domain that was processed */ + fun domain(domain: String) = domain(JsonField.of(domain)) + + /** + * Sets [Builder.domain] to an arbitrary JSON value. + * + * You should usually call [Builder.domain] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun domain(domain: JsonField) = apply { this.domain = domain } + + /** Public URL of the uploaded screenshot image */ + fun screenshot(screenshot: String) = screenshot(JsonField.of(screenshot)) + + /** + * Sets [Builder.screenshot] to an arbitrary JSON value. + * + * You should usually call [Builder.screenshot] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun screenshot(screenshot: JsonField) = apply { this.screenshot = screenshot } + + /** Type of screenshot that was captured */ + fun screenshotType(screenshotType: ScreenshotType) = + screenshotType(JsonField.of(screenshotType)) + + /** + * Sets [Builder.screenshotType] to an arbitrary JSON value. + * + * You should usually call [Builder.screenshotType] with a well-typed [ScreenshotType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun screenshotType(screenshotType: JsonField) = apply { + this.screenshotType = screenshotType + } + + /** Status of the response, e.g., 'ok' */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandScreenshotResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandScreenshotResponse = + BrandScreenshotResponse( + code, + domain, + screenshot, + screenshotType, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrandScreenshotResponse = apply { + if (validated) { + return@apply + } + + code() + domain() + screenshot() + screenshotType().ifPresent { it.validate() } + status() + 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 (code.asKnown().isPresent) 1 else 0) + + (if (domain.asKnown().isPresent) 1 else 0) + + (if (screenshot.asKnown().isPresent) 1 else 0) + + (screenshotType.asKnown().getOrNull()?.validity() ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + /** Type of screenshot that was captured */ + class ScreenshotType @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 VIEWPORT = of("viewport") + + @JvmField val FULL_PAGE = of("fullPage") + + @JvmStatic fun of(value: String) = ScreenshotType(JsonField.of(value)) + } + + /** An enum containing [ScreenshotType]'s known values. */ + enum class Known { + VIEWPORT, + FULL_PAGE, + } + + /** + * An enum containing [ScreenshotType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ScreenshotType] 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 { + VIEWPORT, + FULL_PAGE, + /** + * An enum member indicating that [ScreenshotType] 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) { + VIEWPORT -> Value.VIEWPORT + FULL_PAGE -> Value.FULL_PAGE + 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) { + VIEWPORT -> Known.VIEWPORT + FULL_PAGE -> Known.FULL_PAGE + else -> throw BrandDevInvalidDataException("Unknown ScreenshotType: $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(): ScreenshotType = 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 ScreenshotType && 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 BrandScreenshotResponse && code == other.code && domain == other.domain && screenshot == other.screenshot && screenshotType == other.screenshotType && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, domain, screenshot, screenshotType, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandScreenshotResponse{code=$code, domain=$domain, screenshot=$screenshot, screenshotType=$screenshotType, status=$status, additionalProperties=$additionalProperties}" +} 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 new file mode 100644 index 0000000..ef36b0b --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideParams.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.models.brand + +import com.branddev.api.core.Params +import com.branddev.api.core.checkRequired +import com.branddev.api.core.http.Headers +import com.branddev.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Beta feature: Automatically extract comprehensive design system information from a brand's + * website including colors, typography, spacing, shadows, and UI components. Uses AI-powered + * analysis of website screenshots to identify design patterns and create a reusable styleguide. + */ +class BrandStyleguideParams +private constructor( + private val domain: String, + private val timeoutMs: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The domain will + * be automatically normalized and validated. + */ + fun domain(): String = domain + + /** + * Optional timeout in milliseconds for the request. If the request takes longer than this + * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 + * minutes). + */ + fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandStyleguideParams]. + * + * The following fields are required: + * ```java + * .domain() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandStyleguideParams]. */ + class Builder internal constructor() { + + private var domain: String? = null + private var timeoutMs: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandStyleguideParams: BrandStyleguideParams) = apply { + domain = brandStyleguideParams.domain + timeoutMs = brandStyleguideParams.timeoutMs + additionalHeaders = brandStyleguideParams.additionalHeaders.toBuilder() + additionalQueryParams = brandStyleguideParams.additionalQueryParams.toBuilder() + } + + /** + * Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The domain + * will be automatically normalized and validated. + */ + fun domain(domain: String) = apply { this.domain = domain } + + /** + * Optional timeout in milliseconds for the request. If the request takes longer than this + * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 + * minutes). + */ + fun timeoutMs(timeoutMs: Long?) = apply { this.timeoutMs = timeoutMs } + + /** + * Alias for [Builder.timeoutMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun timeoutMs(timeoutMs: Long) = timeoutMs(timeoutMs as Long?) + + /** Alias for calling [Builder.timeoutMs] with `timeoutMs.orElse(null)`. */ + fun timeoutMs(timeoutMs: Optional) = timeoutMs(timeoutMs.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandStyleguideParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .domain() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandStyleguideParams = + BrandStyleguideParams( + checkRequired("domain", domain), + timeoutMs, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("domain", domain) + timeoutMs?.let { put("timeoutMS", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BrandStyleguideParams && domain == other.domain && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(domain, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "BrandStyleguideParams{domain=$domain, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideResponse.kt new file mode 100644 index 0000000..a2cdecd --- /dev/null +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandStyleguideResponse.kt @@ -0,0 +1,5829 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.models.brand + +import com.branddev.api.core.ExcludeMissing +import com.branddev.api.core.JsonField +import com.branddev.api.core.JsonMissing +import com.branddev.api.core.JsonValue +import com.branddev.api.errors.BrandDevInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BrandStyleguideResponse +private constructor( + private val code: JsonField, + private val domain: JsonField, + private val status: JsonField, + private val styleguide: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("styleguide") + @ExcludeMissing + styleguide: JsonField = JsonMissing.of(), + ) : this(code, domain, status, styleguide, 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") + + /** + * The normalized domain that was processed + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun domain(): Optional = domain.getOptional("domain") + + /** + * Status of the response, e.g., 'ok' + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Comprehensive styleguide data extracted from the website + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun styleguide(): Optional = styleguide.getOptional("styleguide") + + /** + * 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 [domain]. + * + * Unlike [domain], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [styleguide]. + * + * Unlike [styleguide], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("styleguide") + @ExcludeMissing + fun _styleguide(): JsonField = styleguide + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BrandStyleguideResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandStyleguideResponse]. */ + class Builder internal constructor() { + + private var code: JsonField = JsonMissing.of() + private var domain: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var styleguide: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandStyleguideResponse: BrandStyleguideResponse) = apply { + code = brandStyleguideResponse.code + domain = brandStyleguideResponse.domain + status = brandStyleguideResponse.status + styleguide = brandStyleguideResponse.styleguide + additionalProperties = brandStyleguideResponse.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 } + + /** The normalized domain that was processed */ + fun domain(domain: String) = domain(JsonField.of(domain)) + + /** + * Sets [Builder.domain] to an arbitrary JSON value. + * + * You should usually call [Builder.domain] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun domain(domain: JsonField) = apply { this.domain = domain } + + /** Status of the response, e.g., 'ok' */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Comprehensive styleguide data extracted from the website */ + fun styleguide(styleguide: Styleguide) = styleguide(JsonField.of(styleguide)) + + /** + * Sets [Builder.styleguide] to an arbitrary JSON value. + * + * You should usually call [Builder.styleguide] with a well-typed [Styleguide] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun styleguide(styleguide: JsonField) = apply { this.styleguide = styleguide } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandStyleguideResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandStyleguideResponse = + BrandStyleguideResponse( + code, + domain, + status, + styleguide, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrandStyleguideResponse = apply { + if (validated) { + return@apply + } + + code() + domain() + status() + styleguide().ifPresent { it.validate() } + 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 (code.asKnown().isPresent) 1 else 0) + + (if (domain.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (styleguide.asKnown().getOrNull()?.validity() ?: 0) + + /** Comprehensive styleguide data extracted from the website */ + class Styleguide + private constructor( + private val colors: JsonField, + private val components: JsonField, + private val elementSpacing: JsonField, + private val shadows: JsonField, + private val typography: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("colors") @ExcludeMissing colors: JsonField = JsonMissing.of(), + @JsonProperty("components") + @ExcludeMissing + components: JsonField = JsonMissing.of(), + @JsonProperty("elementSpacing") + @ExcludeMissing + elementSpacing: JsonField = JsonMissing.of(), + @JsonProperty("shadows") @ExcludeMissing shadows: JsonField = JsonMissing.of(), + @JsonProperty("typography") + @ExcludeMissing + typography: JsonField = JsonMissing.of(), + ) : this(colors, components, elementSpacing, shadows, typography, mutableMapOf()) + + /** + * Primary colors used on the website + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun colors(): Optional = colors.getOptional("colors") + + /** + * UI component styles + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun components(): Optional = components.getOptional("components") + + /** + * Spacing system used on the website + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun elementSpacing(): Optional = + elementSpacing.getOptional("elementSpacing") + + /** + * Shadow styles used on the website + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun shadows(): Optional = shadows.getOptional("shadows") + + /** + * Typography styles used on the website + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun typography(): Optional = typography.getOptional("typography") + + /** + * Returns the raw JSON value of [colors]. + * + * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField = colors + + /** + * Returns the raw JSON value of [components]. + * + * Unlike [components], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("components") + @ExcludeMissing + fun _components(): JsonField = components + + /** + * Returns the raw JSON value of [elementSpacing]. + * + * Unlike [elementSpacing], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("elementSpacing") + @ExcludeMissing + fun _elementSpacing(): JsonField = elementSpacing + + /** + * Returns the raw JSON value of [shadows]. + * + * Unlike [shadows], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shadows") @ExcludeMissing fun _shadows(): JsonField = shadows + + /** + * Returns the raw JSON value of [typography]. + * + * Unlike [typography], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("typography") + @ExcludeMissing + fun _typography(): JsonField = typography + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Styleguide]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Styleguide]. */ + class Builder internal constructor() { + + private var colors: JsonField = JsonMissing.of() + private var components: JsonField = JsonMissing.of() + private var elementSpacing: JsonField = JsonMissing.of() + private var shadows: JsonField = JsonMissing.of() + private var typography: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(styleguide: Styleguide) = apply { + colors = styleguide.colors + components = styleguide.components + elementSpacing = styleguide.elementSpacing + shadows = styleguide.shadows + typography = styleguide.typography + additionalProperties = styleguide.additionalProperties.toMutableMap() + } + + /** Primary colors used on the website */ + fun colors(colors: Colors) = colors(JsonField.of(colors)) + + /** + * Sets [Builder.colors] to an arbitrary JSON value. + * + * You should usually call [Builder.colors] with a well-typed [Colors] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun colors(colors: JsonField) = apply { this.colors = colors } + + /** UI component styles */ + fun components(components: Components) = components(JsonField.of(components)) + + /** + * Sets [Builder.components] to an arbitrary JSON value. + * + * You should usually call [Builder.components] with a well-typed [Components] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun components(components: JsonField) = apply { + this.components = components + } + + /** Spacing system used on the website */ + fun elementSpacing(elementSpacing: ElementSpacing) = + elementSpacing(JsonField.of(elementSpacing)) + + /** + * Sets [Builder.elementSpacing] to an arbitrary JSON value. + * + * You should usually call [Builder.elementSpacing] with a well-typed [ElementSpacing] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elementSpacing(elementSpacing: JsonField) = apply { + this.elementSpacing = elementSpacing + } + + /** Shadow styles used on the website */ + fun shadows(shadows: Shadows) = shadows(JsonField.of(shadows)) + + /** + * Sets [Builder.shadows] to an arbitrary JSON value. + * + * You should usually call [Builder.shadows] with a well-typed [Shadows] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shadows(shadows: JsonField) = apply { this.shadows = shadows } + + /** Typography styles used on the website */ + fun typography(typography: Typography) = typography(JsonField.of(typography)) + + /** + * Sets [Builder.typography] to an arbitrary JSON value. + * + * You should usually call [Builder.typography] with a well-typed [Typography] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun typography(typography: JsonField) = apply { + this.typography = typography + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Styleguide]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Styleguide = + Styleguide( + colors, + components, + elementSpacing, + shadows, + typography, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Styleguide = apply { + if (validated) { + return@apply + } + + colors().ifPresent { it.validate() } + components().ifPresent { it.validate() } + elementSpacing().ifPresent { it.validate() } + shadows().ifPresent { it.validate() } + typography().ifPresent { it.validate() } + 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 = + (colors.asKnown().getOrNull()?.validity() ?: 0) + + (components.asKnown().getOrNull()?.validity() ?: 0) + + (elementSpacing.asKnown().getOrNull()?.validity() ?: 0) + + (shadows.asKnown().getOrNull()?.validity() ?: 0) + + (typography.asKnown().getOrNull()?.validity() ?: 0) + + /** Primary colors used on the website */ + class Colors + private constructor( + private val accent: JsonField, + private val background: JsonField, + private val text: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accent") + @ExcludeMissing + accent: JsonField = JsonMissing.of(), + @JsonProperty("background") + @ExcludeMissing + background: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(accent, background, text, mutableMapOf()) + + /** + * Accent color of the website (hex format) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun accent(): Optional = accent.getOptional("accent") + + /** + * Background color of the website (hex format) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun background(): Optional = background.getOptional("background") + + /** + * Text color of the website (hex format) + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [accent]. + * + * Unlike [accent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accent") @ExcludeMissing fun _accent(): JsonField = accent + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("background") + @ExcludeMissing + fun _background(): JsonField = background + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Colors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Colors]. */ + class Builder internal constructor() { + + private var accent: JsonField = JsonMissing.of() + private var background: JsonField = JsonMissing.of() + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(colors: Colors) = apply { + accent = colors.accent + background = colors.background + text = colors.text + additionalProperties = colors.additionalProperties.toMutableMap() + } + + /** Accent color of the website (hex format) */ + fun accent(accent: String) = accent(JsonField.of(accent)) + + /** + * Sets [Builder.accent] to an arbitrary JSON value. + * + * You should usually call [Builder.accent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun accent(accent: JsonField) = apply { this.accent = accent } + + /** Background color of the website (hex format) */ + fun background(background: String) = background(JsonField.of(background)) + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun background(background: JsonField) = apply { + this.background = background + } + + /** Text color of the website (hex format) */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Colors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Colors = + Colors(accent, background, text, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Colors = apply { + if (validated) { + return@apply + } + + accent() + background() + text() + 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 (accent.asKnown().isPresent) 1 else 0) + + (if (background.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Colors && accent == other.accent && background == other.background && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accent, background, text, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Colors{accent=$accent, background=$background, text=$text, additionalProperties=$additionalProperties}" + } + + /** UI component styles */ + class Components + private constructor( + private val button: JsonField