diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 25b00795d..2c7ce2d54 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.501.0" + ".": "0.502.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 3e05b57f8..5c2b86552 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 236 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-e3103e9bb8480e11581841c322e0bd0255b64413d401873c96cd00a3e6d6c3f7.yml -openapi_spec_hash: 962e1efe27066cf84b405a6695dd8288 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-31046e3fe86098c429a87dc861cf42dae0252314abf90021a804e748f9c16417.yml +openapi_spec_hash: 78fe78704879172326e842c27ee09a3a config_hash: 4945e03affdf289484733306e4797f81 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c1a995fe..a88f8abc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.502.0 (2026-04-03) + +Full Changelog: [v0.501.0...v0.502.0](https://github.com/Increase/increase-java/compare/v0.501.0...v0.502.0) + +### Features + +* **api:** api update ([fca194b](https://github.com/Increase/increase-java/commit/fca194b283ed94517b390e14ce5879549cdcbf51)) + ## 0.501.0 (2026-04-02) Full Changelog: [v0.500.0...v0.501.0](https://github.com/Increase/increase-java/compare/v0.500.0...v0.501.0) diff --git a/README.md b/README.md index 733951020..d637a0d47 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.501.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.501.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.501.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.502.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.502.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.502.0) @@ -13,7 +13,7 @@ The Increase Java SDK is similar to the Increase Kotlin SDK but with minor diffe -The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.501.0). +The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.502.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d ### Gradle ```kotlin -implementation("com.increase.api:increase-java:0.501.0") +implementation("com.increase.api:increase-java:0.502.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.501.0") com.increase.api increase-java - 0.501.0 + 0.502.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index fa9d63672..47043d8d2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.501.0" // x-release-please-version + version = "0.502.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cards/Card.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cards/Card.kt index 1b2d3ea8c..dd27c80be 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/cards/Card.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cards/Card.kt @@ -11,7 +11,9 @@ import com.increase.api.core.ExcludeMissing import com.increase.api.core.JsonField import com.increase.api.core.JsonMissing import com.increase.api.core.JsonValue +import com.increase.api.core.checkKnown import com.increase.api.core.checkRequired +import com.increase.api.core.toImmutable import com.increase.api.errors.IncreaseInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -29,6 +31,7 @@ class Card private constructor( private val id: JsonField, private val accountId: JsonField, + private val authorizationControls: JsonField, private val billingAddress: JsonField, private val createdAt: JsonField, private val description: JsonField, @@ -47,6 +50,9 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("authorization_controls") + @ExcludeMissing + authorizationControls: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -75,6 +81,7 @@ private constructor( ) : this( id, accountId, + authorizationControls, billingAddress, createdAt, description, @@ -105,6 +112,15 @@ private constructor( */ fun accountId(): String = accountId.getRequired("account_id") + /** + * Controls that restrict how this card can be used. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authorizationControls(): Optional = + authorizationControls.getOptional("authorization_controls") + /** * The Card's billing address. * @@ -211,6 +227,16 @@ private constructor( */ @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + /** + * Returns the raw JSON value of [authorizationControls]. + * + * Unlike [authorizationControls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorization_controls") + @ExcludeMissing + fun _authorizationControls(): JsonField = authorizationControls + /** * Returns the raw JSON value of [billingAddress]. * @@ -321,6 +347,7 @@ private constructor( * ```java * .id() * .accountId() + * .authorizationControls() * .billingAddress() * .createdAt() * .description() @@ -342,6 +369,7 @@ private constructor( private var id: JsonField? = null private var accountId: JsonField? = null + private var authorizationControls: JsonField? = null private var billingAddress: JsonField? = null private var createdAt: JsonField? = null private var description: JsonField? = null @@ -359,6 +387,7 @@ private constructor( internal fun from(card: Card) = apply { id = card.id accountId = card.accountId + authorizationControls = card.authorizationControls billingAddress = card.billingAddress createdAt = card.createdAt description = card.description @@ -396,6 +425,28 @@ private constructor( */ fun accountId(accountId: JsonField) = apply { this.accountId = accountId } + /** Controls that restrict how this card can be used. */ + fun authorizationControls(authorizationControls: AuthorizationControls?) = + authorizationControls(JsonField.ofNullable(authorizationControls)) + + /** + * Alias for calling [Builder.authorizationControls] with + * `authorizationControls.orElse(null)`. + */ + fun authorizationControls(authorizationControls: Optional) = + authorizationControls(authorizationControls.getOrNull()) + + /** + * Sets [Builder.authorizationControls] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationControls] with a well-typed + * [AuthorizationControls] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authorizationControls(authorizationControls: JsonField) = apply { + this.authorizationControls = authorizationControls + } + /** The Card's billing address. */ fun billingAddress(billingAddress: BillingAddress) = billingAddress(JsonField.of(billingAddress)) @@ -591,6 +642,7 @@ private constructor( * ```java * .id() * .accountId() + * .authorizationControls() * .billingAddress() * .createdAt() * .description() @@ -610,6 +662,7 @@ private constructor( Card( checkRequired("id", id), checkRequired("accountId", accountId), + checkRequired("authorizationControls", authorizationControls), checkRequired("billingAddress", billingAddress), checkRequired("createdAt", createdAt), checkRequired("description", description), @@ -634,6 +687,7 @@ private constructor( id() accountId() + authorizationControls().ifPresent { it.validate() } billingAddress().validate() createdAt() description() @@ -665,6 +719,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (accountId.asKnown().isPresent) 1 else 0) + + (authorizationControls.asKnown().getOrNull()?.validity() ?: 0) + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + @@ -677,6 +732,3021 @@ private constructor( (status.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + /** Controls that restrict how this card can be used. */ + class AuthorizationControls + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val maximumAuthorizationCount: JsonField, + private val merchantAcceptorIdentifier: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCountry: JsonField, + private val spendingLimits: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maximum_authorization_count") + @ExcludeMissing + maximumAuthorizationCount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_identifier") + @ExcludeMissing + merchantAcceptorIdentifier: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_country") + @ExcludeMissing + merchantCountry: JsonField = JsonMissing.of(), + @JsonProperty("spending_limits") + @ExcludeMissing + spendingLimits: JsonField> = JsonMissing.of(), + ) : this( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + spendingLimits, + mutableMapOf(), + ) + + /** + * Limits the number of authorizations that can be approved on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maximumAuthorizationCount(): Optional = + maximumAuthorizationCount.getOptional("maximum_authorization_count") + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantAcceptorIdentifier(): Optional = + merchantAcceptorIdentifier.getOptional("merchant_acceptor_identifier") + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCategoryCode(): Optional = + merchantCategoryCode.getOptional("merchant_category_code") + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCountry(): Optional = + merchantCountry.getOptional("merchant_country") + + /** + * Spending limits for this card. The most restrictive limit is applied if multiple limits + * match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun spendingLimits(): Optional> = + spendingLimits.getOptional("spending_limits") + + /** + * Returns the raw JSON value of [maximumAuthorizationCount]. + * + * Unlike [maximumAuthorizationCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_authorization_count") + @ExcludeMissing + fun _maximumAuthorizationCount(): JsonField = + maximumAuthorizationCount + + /** + * Returns the raw JSON value of [merchantAcceptorIdentifier]. + * + * Unlike [merchantAcceptorIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_acceptor_identifier") + @ExcludeMissing + fun _merchantAcceptorIdentifier(): JsonField = + merchantAcceptorIdentifier + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_code") + @ExcludeMissing + fun _merchantCategoryCode(): JsonField = merchantCategoryCode + + /** + * Returns the raw JSON value of [merchantCountry]. + * + * Unlike [merchantCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_country") + @ExcludeMissing + fun _merchantCountry(): JsonField = merchantCountry + + /** + * Returns the raw JSON value of [spendingLimits]. + * + * Unlike [spendingLimits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spending_limits") + @ExcludeMissing + fun _spendingLimits(): JsonField> = spendingLimits + + @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 [AuthorizationControls]. + * + * The following fields are required: + * ```java + * .maximumAuthorizationCount() + * .merchantAcceptorIdentifier() + * .merchantCategoryCode() + * .merchantCountry() + * .spendingLimits() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthorizationControls]. */ + class Builder internal constructor() { + + private var maximumAuthorizationCount: JsonField? = null + private var merchantAcceptorIdentifier: JsonField? = null + private var merchantCategoryCode: JsonField? = null + private var merchantCountry: JsonField? = null + private var spendingLimits: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authorizationControls: AuthorizationControls) = apply { + maximumAuthorizationCount = authorizationControls.maximumAuthorizationCount + merchantAcceptorIdentifier = authorizationControls.merchantAcceptorIdentifier + merchantCategoryCode = authorizationControls.merchantCategoryCode + merchantCountry = authorizationControls.merchantCountry + spendingLimits = authorizationControls.spendingLimits.map { it.toMutableList() } + additionalProperties = authorizationControls.additionalProperties.toMutableMap() + } + + /** Limits the number of authorizations that can be approved on this card. */ + fun maximumAuthorizationCount(maximumAuthorizationCount: MaximumAuthorizationCount?) = + maximumAuthorizationCount(JsonField.ofNullable(maximumAuthorizationCount)) + + /** + * Alias for calling [Builder.maximumAuthorizationCount] with + * `maximumAuthorizationCount.orElse(null)`. + */ + fun maximumAuthorizationCount( + maximumAuthorizationCount: Optional + ) = maximumAuthorizationCount(maximumAuthorizationCount.getOrNull()) + + /** + * Sets [Builder.maximumAuthorizationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAuthorizationCount] with a well-typed + * [MaximumAuthorizationCount] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun maximumAuthorizationCount( + maximumAuthorizationCount: JsonField + ) = apply { this.maximumAuthorizationCount = maximumAuthorizationCount } + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on + * this card. + */ + fun merchantAcceptorIdentifier( + merchantAcceptorIdentifier: MerchantAcceptorIdentifier? + ) = merchantAcceptorIdentifier(JsonField.ofNullable(merchantAcceptorIdentifier)) + + /** + * Alias for calling [Builder.merchantAcceptorIdentifier] with + * `merchantAcceptorIdentifier.orElse(null)`. + */ + fun merchantAcceptorIdentifier( + merchantAcceptorIdentifier: Optional + ) = merchantAcceptorIdentifier(merchantAcceptorIdentifier.getOrNull()) + + /** + * Sets [Builder.merchantAcceptorIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAcceptorIdentifier] with a well-typed + * [MerchantAcceptorIdentifier] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchantAcceptorIdentifier( + merchantAcceptorIdentifier: JsonField + ) = apply { this.merchantAcceptorIdentifier = merchantAcceptorIdentifier } + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on + * this card. + */ + fun merchantCategoryCode(merchantCategoryCode: MerchantCategoryCode?) = + merchantCategoryCode(JsonField.ofNullable(merchantCategoryCode)) + + /** + * Alias for calling [Builder.merchantCategoryCode] with + * `merchantCategoryCode.orElse(null)`. + */ + fun merchantCategoryCode(merchantCategoryCode: Optional) = + merchantCategoryCode(merchantCategoryCode.getOrNull()) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed + * [MerchantCategoryCode] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = + apply { + this.merchantCategoryCode = merchantCategoryCode + } + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + */ + fun merchantCountry(merchantCountry: MerchantCountry?) = + merchantCountry(JsonField.ofNullable(merchantCountry)) + + /** Alias for calling [Builder.merchantCountry] with `merchantCountry.orElse(null)`. */ + fun merchantCountry(merchantCountry: Optional) = + merchantCountry(merchantCountry.getOrNull()) + + /** + * Sets [Builder.merchantCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCountry] with a well-typed [MerchantCountry] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun merchantCountry(merchantCountry: JsonField) = apply { + this.merchantCountry = merchantCountry + } + + /** + * Spending limits for this card. The most restrictive limit is applied if multiple + * limits match. + */ + fun spendingLimits(spendingLimits: List?) = + spendingLimits(JsonField.ofNullable(spendingLimits)) + + /** Alias for calling [Builder.spendingLimits] with `spendingLimits.orElse(null)`. */ + fun spendingLimits(spendingLimits: Optional>) = + spendingLimits(spendingLimits.getOrNull()) + + /** + * Sets [Builder.spendingLimits] to an arbitrary JSON value. + * + * You should usually call [Builder.spendingLimits] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun spendingLimits(spendingLimits: JsonField>) = apply { + this.spendingLimits = spendingLimits.map { it.toMutableList() } + } + + /** + * Adds a single [SpendingLimit] to [spendingLimits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpendingLimit(spendingLimit: SpendingLimit) = apply { + spendingLimits = + (spendingLimits ?: JsonField.of(mutableListOf())).also { + checkKnown("spendingLimits", it).add(spendingLimit) + } + } + + 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 [AuthorizationControls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maximumAuthorizationCount() + * .merchantAcceptorIdentifier() + * .merchantCategoryCode() + * .merchantCountry() + * .spendingLimits() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AuthorizationControls = + AuthorizationControls( + checkRequired("maximumAuthorizationCount", maximumAuthorizationCount), + checkRequired("merchantAcceptorIdentifier", merchantAcceptorIdentifier), + checkRequired("merchantCategoryCode", merchantCategoryCode), + checkRequired("merchantCountry", merchantCountry), + checkRequired("spendingLimits", spendingLimits).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuthorizationControls = apply { + if (validated) { + return@apply + } + + maximumAuthorizationCount().ifPresent { it.validate() } + merchantAcceptorIdentifier().ifPresent { it.validate() } + merchantCategoryCode().ifPresent { it.validate() } + merchantCountry().ifPresent { it.validate() } + spendingLimits().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (maximumAuthorizationCount.asKnown().getOrNull()?.validity() ?: 0) + + (merchantAcceptorIdentifier.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCategoryCode.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCountry.asKnown().getOrNull()?.validity() ?: 0) + + (spendingLimits.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Limits the number of authorizations that can be approved on this card. */ + class MaximumAuthorizationCount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("all_time") + @ExcludeMissing + allTime: JsonField = JsonMissing.of() + ) : this(allTime, mutableMapOf()) + + /** + * The maximum number of authorizations that can be approved on this card over its + * lifetime. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allTime(): Optional = allTime.getOptional("all_time") + + /** + * Returns the raw JSON value of [allTime]. + * + * Unlike [allTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("all_time") @ExcludeMissing fun _allTime(): JsonField = allTime + + @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 + * [MaximumAuthorizationCount]. + * + * The following fields are required: + * ```java + * .allTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumAuthorizationCount]. */ + class Builder internal constructor() { + + private var allTime: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAuthorizationCount: MaximumAuthorizationCount) = apply { + allTime = maximumAuthorizationCount.allTime + additionalProperties = + maximumAuthorizationCount.additionalProperties.toMutableMap() + } + + /** + * The maximum number of authorizations that can be approved on this card over its + * lifetime. + */ + fun allTime(allTime: Long?) = allTime(JsonField.ofNullable(allTime)) + + /** + * Alias for [Builder.allTime]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allTime(allTime: Long) = allTime(allTime as Long?) + + /** Alias for calling [Builder.allTime] with `allTime.orElse(null)`. */ + fun allTime(allTime: Optional) = allTime(allTime.getOrNull()) + + /** + * Sets [Builder.allTime] to an arbitrary JSON value. + * + * You should usually call [Builder.allTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allTime(allTime: JsonField) = apply { this.allTime = allTime } + + 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 [MaximumAuthorizationCount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaximumAuthorizationCount = + MaximumAuthorizationCount( + checkRequired("allTime", allTime), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaximumAuthorizationCount = apply { + if (validated) { + return@apply + } + + allTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (allTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaximumAuthorizationCount && + allTime == other.allTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allTime, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumAuthorizationCount{allTime=$allTime, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on this + * card. + */ + class MerchantAcceptorIdentifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The Merchant Acceptor IDs that are allowed for authorizations on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The Merchant Acceptor IDs that are blocked for authorizations on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 + * [MerchantAcceptorIdentifier]. + * + * The following fields are required: + * ```java + * .allowed() + * .blocked() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantAcceptorIdentifier]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantAcceptorIdentifier: MerchantAcceptorIdentifier) = apply { + allowed = merchantAcceptorIdentifier.allowed.map { it.toMutableList() } + blocked = merchantAcceptorIdentifier.blocked.map { it.toMutableList() } + additionalProperties = + merchantAcceptorIdentifier.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor IDs that are allowed for authorizations on this card. */ + fun allowed(allowed: List?) = allowed(JsonField.ofNullable(allowed)) + + /** Alias for calling [Builder.allowed] with `allowed.orElse(null)`. */ + fun allowed(allowed: Optional>) = allowed(allowed.getOrNull()) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** The Merchant Acceptor IDs that are blocked for authorizations on this card. */ + fun blocked(blocked: List?) = blocked(JsonField.ofNullable(blocked)) + + /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ + fun blocked(blocked: Optional>) = blocked(blocked.getOrNull()) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantAcceptorIdentifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * .blocked() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantAcceptorIdentifier = + MerchantAcceptorIdentifier( + checkRequired("allowed", allowed).map { it.toImmutable() }, + checkRequired("blocked", blocked).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantAcceptorIdentifier = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val identifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("identifier") + @ExcludeMissing + identifier: JsonField = JsonMissing.of() + ) : this(identifier, mutableMapOf()) + + /** + * The Merchant Acceptor ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun identifier(): String = identifier.getRequired("identifier") + + /** + * Returns the raw JSON value of [identifier]. + * + * Unlike [identifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("identifier") + @ExcludeMissing + fun _identifier(): JsonField = identifier + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var identifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + identifier = allowed.identifier + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor ID. */ + fun identifier(identifier: String) = identifier(JsonField.of(identifier)) + + /** + * Sets [Builder.identifier] to an arbitrary JSON value. + * + * You should usually call [Builder.identifier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identifier(identifier: JsonField) = apply { + this.identifier = identifier + } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed( + checkRequired("identifier", identifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + identifier() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (identifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + identifier == other.identifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(identifier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{identifier=$identifier, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val identifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("identifier") + @ExcludeMissing + identifier: JsonField = JsonMissing.of() + ) : this(identifier, mutableMapOf()) + + /** + * The Merchant Acceptor ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun identifier(): String = identifier.getRequired("identifier") + + /** + * Returns the raw JSON value of [identifier]. + * + * Unlike [identifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("identifier") + @ExcludeMissing + fun _identifier(): JsonField = identifier + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var identifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + identifier = blocked.identifier + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor ID. */ + fun identifier(identifier: String) = identifier(JsonField.of(identifier)) + + /** + * Sets [Builder.identifier] to an arbitrary JSON value. + * + * You should usually call [Builder.identifier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identifier(identifier: JsonField) = apply { + this.identifier = identifier + } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked( + checkRequired("identifier", identifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + identifier() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (identifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + identifier == other.identifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(identifier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{identifier=$identifier, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantAcceptorIdentifier && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantAcceptorIdentifier{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on this + * card. + */ + class MerchantCategoryCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The Merchant Category Codes that are allowed for authorizations on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The Merchant Category Codes that are blocked for authorizations on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 [MerchantCategoryCode]. + * + * The following fields are required: + * ```java + * .allowed() + * .blocked() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCategoryCode]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCategoryCode: MerchantCategoryCode) = apply { + allowed = merchantCategoryCode.allowed.map { it.toMutableList() } + blocked = merchantCategoryCode.blocked.map { it.toMutableList() } + additionalProperties = merchantCategoryCode.additionalProperties.toMutableMap() + } + + /** The Merchant Category Codes that are allowed for authorizations on this card. */ + fun allowed(allowed: List?) = allowed(JsonField.ofNullable(allowed)) + + /** Alias for calling [Builder.allowed] with `allowed.orElse(null)`. */ + fun allowed(allowed: Optional>) = allowed(allowed.getOrNull()) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** The Merchant Category Codes that are blocked for authorizations on this card. */ + fun blocked(blocked: List?) = blocked(JsonField.ofNullable(blocked)) + + /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ + fun blocked(blocked: Optional>) = blocked(blocked.getOrNull()) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantCategoryCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * .blocked() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCategoryCode = + MerchantCategoryCode( + checkRequired("allowed", allowed).map { it.toImmutable() }, + checkRequired("blocked", blocked).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCategoryCode = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code (MCC). + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + code = allowed.code + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code (MCC). */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed(checkRequired("code", code), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{code=$code, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code (MCC). + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + code = blocked.code + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code (MCC). */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked(checkRequired("code", code), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{code=$code, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCategoryCode && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCategoryCode{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + */ + class MerchantCountry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The merchant countries that are allowed for authorizations on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The merchant countries that are blocked for authorizations on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 [MerchantCountry]. + * + * The following fields are required: + * ```java + * .allowed() + * .blocked() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCountry]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCountry: MerchantCountry) = apply { + allowed = merchantCountry.allowed.map { it.toMutableList() } + blocked = merchantCountry.blocked.map { it.toMutableList() } + additionalProperties = merchantCountry.additionalProperties.toMutableMap() + } + + /** The merchant countries that are allowed for authorizations on this card. */ + fun allowed(allowed: List?) = allowed(JsonField.ofNullable(allowed)) + + /** Alias for calling [Builder.allowed] with `allowed.orElse(null)`. */ + fun allowed(allowed: Optional>) = allowed(allowed.getOrNull()) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** The merchant countries that are blocked for authorizations on this card. */ + fun blocked(blocked: List?) = blocked(JsonField.ofNullable(blocked)) + + /** Alias for calling [Builder.blocked] with `blocked.orElse(null)`. */ + fun blocked(blocked: Optional>) = blocked(blocked.getOrNull()) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantCountry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * .blocked() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCountry = + MerchantCountry( + checkRequired("allowed", allowed).map { it.toImmutable() }, + checkRequired("blocked", blocked).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCountry = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val country: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of() + ) : this(country, mutableMapOf()) + + /** + * The ISO 3166-1 alpha-2 country code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .country() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + country = allowed.country + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The ISO 3166-1 alpha-2 country code. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .country() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed( + checkRequired("country", country), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + country() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (country.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + country == other.country && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(country, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{country=$country, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val country: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of() + ) : this(country, mutableMapOf()) + + /** + * The ISO 3166-1 alpha-2 country code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .country() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + country = blocked.country + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The ISO 3166-1 alpha-2 country code. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .country() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked( + checkRequired("country", country), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + country() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (country.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + country == other.country && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(country, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{country=$country, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCountry && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCountry{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + class SpendingLimit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val interval: JsonField, + private val merchantCategoryCodes: JsonField>, + private val settlementAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("interval") + @ExcludeMissing + interval: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_codes") + @ExcludeMissing + merchantCategoryCodes: JsonField> = JsonMissing.of(), + @JsonProperty("settlement_amount") + @ExcludeMissing + settlementAmount: JsonField = JsonMissing.of(), + ) : this(interval, merchantCategoryCodes, settlementAmount, mutableMapOf()) + + /** + * The interval at which the spending limit is enforced. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun interval(): Interval = interval.getRequired("interval") + + /** + * The Merchant Category Codes (MCCs) this spending limit applies to. If not set, the + * limit applies to all transactions. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantCategoryCodes(): Optional> = + merchantCategoryCodes.getOptional("merchant_category_codes") + + /** + * The maximum settlement amount permitted in the given interval. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun settlementAmount(): Long = settlementAmount.getRequired("settlement_amount") + + /** + * Returns the raw JSON value of [interval]. + * + * Unlike [interval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interval") + @ExcludeMissing + fun _interval(): JsonField = interval + + /** + * Returns the raw JSON value of [merchantCategoryCodes]. + * + * Unlike [merchantCategoryCodes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_codes") + @ExcludeMissing + fun _merchantCategoryCodes(): JsonField> = + merchantCategoryCodes + + /** + * Returns the raw JSON value of [settlementAmount]. + * + * Unlike [settlementAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_amount") + @ExcludeMissing + fun _settlementAmount(): JsonField = settlementAmount + + @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 [SpendingLimit]. + * + * The following fields are required: + * ```java + * .interval() + * .merchantCategoryCodes() + * .settlementAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpendingLimit]. */ + class Builder internal constructor() { + + private var interval: JsonField? = null + private var merchantCategoryCodes: JsonField>? = + null + private var settlementAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spendingLimit: SpendingLimit) = apply { + interval = spendingLimit.interval + merchantCategoryCodes = + spendingLimit.merchantCategoryCodes.map { it.toMutableList() } + settlementAmount = spendingLimit.settlementAmount + additionalProperties = spendingLimit.additionalProperties.toMutableMap() + } + + /** The interval at which the spending limit is enforced. */ + fun interval(interval: Interval) = interval(JsonField.of(interval)) + + /** + * Sets [Builder.interval] to an arbitrary JSON value. + * + * You should usually call [Builder.interval] with a well-typed [Interval] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun interval(interval: JsonField) = apply { this.interval = interval } + + /** + * The Merchant Category Codes (MCCs) this spending limit applies to. If not set, + * the limit applies to all transactions. + */ + fun merchantCategoryCodes(merchantCategoryCodes: List?) = + merchantCategoryCodes(JsonField.ofNullable(merchantCategoryCodes)) + + /** + * Alias for calling [Builder.merchantCategoryCodes] with + * `merchantCategoryCodes.orElse(null)`. + */ + fun merchantCategoryCodes( + merchantCategoryCodes: Optional> + ) = merchantCategoryCodes(merchantCategoryCodes.getOrNull()) + + /** + * Sets [Builder.merchantCategoryCodes] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCodes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantCategoryCodes( + merchantCategoryCodes: JsonField> + ) = apply { + this.merchantCategoryCodes = merchantCategoryCodes.map { it.toMutableList() } + } + + /** + * Adds a single [MerchantCategoryCode] to [merchantCategoryCodes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMerchantCategoryCode(merchantCategoryCode: MerchantCategoryCode) = apply { + merchantCategoryCodes = + (merchantCategoryCodes ?: JsonField.of(mutableListOf())).also { + checkKnown("merchantCategoryCodes", it).add(merchantCategoryCode) + } + } + + /** The maximum settlement amount permitted in the given interval. */ + fun settlementAmount(settlementAmount: Long) = + settlementAmount(JsonField.of(settlementAmount)) + + /** + * Sets [Builder.settlementAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun settlementAmount(settlementAmount: JsonField) = apply { + this.settlementAmount = settlementAmount + } + + 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 [SpendingLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .interval() + * .merchantCategoryCodes() + * .settlementAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendingLimit = + SpendingLimit( + checkRequired("interval", interval), + checkRequired("merchantCategoryCodes", merchantCategoryCodes).map { + it.toImmutable() + }, + checkRequired("settlementAmount", settlementAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SpendingLimit = apply { + if (validated) { + return@apply + } + + interval().validate() + merchantCategoryCodes().ifPresent { it.forEach { it.validate() } } + settlementAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (interval.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCategoryCodes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (settlementAmount.asKnown().isPresent) 1 else 0) + + /** The interval at which the spending limit is enforced. */ + class Interval @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 { + + /** The spending limit applies over the lifetime of the card. */ + @JvmField val ALL_TIME = of("all_time") + + /** The spending limit applies per transaction. */ + @JvmField val PER_TRANSACTION = of("per_transaction") + + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + @JvmField val PER_DAY = of("per_day") + + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + @JvmField val PER_WEEK = of("per_week") + + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + @JvmField val PER_MONTH = of("per_month") + + @JvmStatic fun of(value: String) = Interval(JsonField.of(value)) + } + + /** An enum containing [Interval]'s known values. */ + enum class Known { + /** The spending limit applies over the lifetime of the card. */ + ALL_TIME, + /** The spending limit applies per transaction. */ + PER_TRANSACTION, + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + PER_DAY, + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + PER_WEEK, + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + PER_MONTH, + } + + /** + * An enum containing [Interval]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Interval] 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 { + /** The spending limit applies over the lifetime of the card. */ + ALL_TIME, + /** The spending limit applies per transaction. */ + PER_TRANSACTION, + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + PER_DAY, + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + PER_WEEK, + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + PER_MONTH, + /** + * An enum member indicating that [Interval] 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) { + ALL_TIME -> Value.ALL_TIME + PER_TRANSACTION -> Value.PER_TRANSACTION + PER_DAY -> Value.PER_DAY + PER_WEEK -> Value.PER_WEEK + PER_MONTH -> Value.PER_MONTH + 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 IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ALL_TIME -> Known.ALL_TIME + PER_TRANSACTION -> Known.PER_TRANSACTION + PER_DAY -> Known.PER_DAY + PER_WEEK -> Known.PER_WEEK + PER_MONTH -> Known.PER_MONTH + else -> throw IncreaseInvalidDataException("Unknown Interval: $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 IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Interval = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 other is Interval && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MerchantCategoryCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code (MCC). + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 + * [MerchantCategoryCode]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCategoryCode]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCategoryCode: MerchantCategoryCode) = apply { + code = merchantCategoryCode.code + additionalProperties = + merchantCategoryCode.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code (MCC). */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [MerchantCategoryCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCategoryCode = + MerchantCategoryCode( + checkRequired("code", code), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCategoryCode = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCategoryCode && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCategoryCode{code=$code, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendingLimit && + interval == other.interval && + merchantCategoryCodes == other.merchantCategoryCodes && + settlementAmount == other.settlementAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + interval, + merchantCategoryCodes, + settlementAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpendingLimit{interval=$interval, merchantCategoryCodes=$merchantCategoryCodes, settlementAmount=$settlementAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthorizationControls && + maximumAuthorizationCount == other.maximumAuthorizationCount && + merchantAcceptorIdentifier == other.merchantAcceptorIdentifier && + merchantCategoryCode == other.merchantCategoryCode && + merchantCountry == other.merchantCountry && + spendingLimits == other.spendingLimits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + spendingLimits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthorizationControls{maximumAuthorizationCount=$maximumAuthorizationCount, merchantAcceptorIdentifier=$merchantAcceptorIdentifier, merchantCategoryCode=$merchantCategoryCode, merchantCountry=$merchantCountry, spendingLimits=$spendingLimits, additionalProperties=$additionalProperties}" + } + /** The Card's billing address. */ class BillingAddress @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -1555,6 +4625,7 @@ private constructor( return other is Card && id == other.id && accountId == other.accountId && + authorizationControls == other.authorizationControls && billingAddress == other.billingAddress && createdAt == other.createdAt && description == other.description && @@ -1573,6 +4644,7 @@ private constructor( Objects.hash( id, accountId, + authorizationControls, billingAddress, createdAt, description, @@ -1591,5 +4663,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Card{id=$id, accountId=$accountId, billingAddress=$billingAddress, createdAt=$createdAt, description=$description, digitalWallet=$digitalWallet, entityId=$entityId, expirationMonth=$expirationMonth, expirationYear=$expirationYear, idempotencyKey=$idempotencyKey, last4=$last4, status=$status, type=$type, additionalProperties=$additionalProperties}" + "Card{id=$id, accountId=$accountId, authorizationControls=$authorizationControls, billingAddress=$billingAddress, createdAt=$createdAt, description=$description, digitalWallet=$digitalWallet, entityId=$entityId, expirationMonth=$expirationMonth, expirationYear=$expirationYear, idempotencyKey=$idempotencyKey, last4=$last4, status=$status, type=$type, additionalProperties=$additionalProperties}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardCreateParams.kt index f4ee6b0be..e16e03975 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardCreateParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardCreateParams.kt @@ -6,14 +6,17 @@ 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 com.increase.api.core.Enum import com.increase.api.core.ExcludeMissing import com.increase.api.core.JsonField import com.increase.api.core.JsonMissing import com.increase.api.core.JsonValue import com.increase.api.core.Params +import com.increase.api.core.checkKnown import com.increase.api.core.checkRequired import com.increase.api.core.http.Headers import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable import com.increase.api.errors.IncreaseInvalidDataException import java.util.Collections import java.util.Objects @@ -36,6 +39,14 @@ private constructor( */ fun accountId(): String = body.accountId() + /** + * Controls that restrict how this card can be used. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authorizationControls(): Optional = body.authorizationControls() + /** * The card's billing address. * @@ -79,6 +90,14 @@ private constructor( */ fun _accountId(): JsonField = body._accountId() + /** + * Returns the raw JSON value of [authorizationControls]. + * + * Unlike [authorizationControls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _authorizationControls(): JsonField = body._authorizationControls() + /** * Returns the raw JSON value of [billingAddress]. * @@ -150,10 +169,10 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [accountId] + * - [authorizationControls] * - [billingAddress] * - [description] * - [digitalWallet] - * - [entityId] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -170,6 +189,22 @@ private constructor( */ fun accountId(accountId: JsonField) = apply { body.accountId(accountId) } + /** Controls that restrict how this card can be used. */ + fun authorizationControls(authorizationControls: AuthorizationControls) = apply { + body.authorizationControls(authorizationControls) + } + + /** + * Sets [Builder.authorizationControls] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationControls] with a well-typed + * [AuthorizationControls] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authorizationControls(authorizationControls: JsonField) = apply { + body.authorizationControls(authorizationControls) + } + /** The card's billing address. */ fun billingAddress(billingAddress: BillingAddress) = apply { body.billingAddress(billingAddress) @@ -376,6 +411,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, + private val authorizationControls: JsonField, private val billingAddress: JsonField, private val description: JsonField, private val digitalWallet: JsonField, @@ -388,6 +424,9 @@ private constructor( @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("authorization_controls") + @ExcludeMissing + authorizationControls: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -400,7 +439,15 @@ private constructor( @JsonProperty("entity_id") @ExcludeMissing entityId: JsonField = JsonMissing.of(), - ) : this(accountId, billingAddress, description, digitalWallet, entityId, mutableMapOf()) + ) : this( + accountId, + authorizationControls, + billingAddress, + description, + digitalWallet, + entityId, + mutableMapOf(), + ) /** * The Account the card should belong to. @@ -410,6 +457,15 @@ private constructor( */ fun accountId(): String = accountId.getRequired("account_id") + /** + * Controls that restrict how this card can be used. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun authorizationControls(): Optional = + authorizationControls.getOptional("authorization_controls") + /** * The card's billing address. * @@ -454,6 +510,16 @@ private constructor( */ @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + /** + * Returns the raw JSON value of [authorizationControls]. + * + * Unlike [authorizationControls], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authorization_controls") + @ExcludeMissing + fun _authorizationControls(): JsonField = authorizationControls + /** * Returns the raw JSON value of [billingAddress]. * @@ -519,6 +585,7 @@ private constructor( class Builder internal constructor() { private var accountId: JsonField? = null + private var authorizationControls: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var digitalWallet: JsonField = JsonMissing.of() @@ -528,6 +595,7 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { accountId = body.accountId + authorizationControls = body.authorizationControls billingAddress = body.billingAddress description = body.description digitalWallet = body.digitalWallet @@ -547,6 +615,22 @@ private constructor( */ fun accountId(accountId: JsonField) = apply { this.accountId = accountId } + /** Controls that restrict how this card can be used. */ + fun authorizationControls(authorizationControls: AuthorizationControls) = + authorizationControls(JsonField.of(authorizationControls)) + + /** + * Sets [Builder.authorizationControls] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationControls] with a well-typed + * [AuthorizationControls] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun authorizationControls(authorizationControls: JsonField) = + apply { + this.authorizationControls = authorizationControls + } + /** The card's billing address. */ fun billingAddress(billingAddress: BillingAddress) = billingAddress(JsonField.of(billingAddress)) @@ -646,6 +730,7 @@ private constructor( fun build(): Body = Body( checkRequired("accountId", accountId), + authorizationControls, billingAddress, description, digitalWallet, @@ -662,6 +747,7 @@ private constructor( } accountId() + authorizationControls().ifPresent { it.validate() } billingAddress().ifPresent { it.validate() } description() digitalWallet().ifPresent { it.validate() } @@ -686,6 +772,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (accountId.asKnown().isPresent) 1 else 0) + + (authorizationControls.asKnown().getOrNull()?.validity() ?: 0) + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (digitalWallet.asKnown().getOrNull()?.validity() ?: 0) + @@ -698,6 +785,7 @@ private constructor( return other is Body && accountId == other.accountId && + authorizationControls == other.authorizationControls && billingAddress == other.billingAddress && description == other.description && digitalWallet == other.digitalWallet && @@ -708,6 +796,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( accountId, + authorizationControls, billingAddress, description, digitalWallet, @@ -719,7 +808,2913 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{accountId=$accountId, billingAddress=$billingAddress, description=$description, digitalWallet=$digitalWallet, entityId=$entityId, additionalProperties=$additionalProperties}" + "Body{accountId=$accountId, authorizationControls=$authorizationControls, billingAddress=$billingAddress, description=$description, digitalWallet=$digitalWallet, entityId=$entityId, additionalProperties=$additionalProperties}" + } + + /** Controls that restrict how this card can be used. */ + class AuthorizationControls + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val maximumAuthorizationCount: JsonField, + private val merchantAcceptorIdentifier: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCountry: JsonField, + private val spendingLimits: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maximum_authorization_count") + @ExcludeMissing + maximumAuthorizationCount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_identifier") + @ExcludeMissing + merchantAcceptorIdentifier: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_country") + @ExcludeMissing + merchantCountry: JsonField = JsonMissing.of(), + @JsonProperty("spending_limits") + @ExcludeMissing + spendingLimits: JsonField> = JsonMissing.of(), + ) : this( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + spendingLimits, + mutableMapOf(), + ) + + /** + * Limits the number of authorizations that can be approved on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maximumAuthorizationCount(): Optional = + maximumAuthorizationCount.getOptional("maximum_authorization_count") + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantAcceptorIdentifier(): Optional = + merchantAcceptorIdentifier.getOptional("merchant_acceptor_identifier") + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCategoryCode(): Optional = + merchantCategoryCode.getOptional("merchant_category_code") + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCountry(): Optional = + merchantCountry.getOptional("merchant_country") + + /** + * Spending limits for this card. The most restrictive limit is applied if multiple limits + * match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun spendingLimits(): Optional> = + spendingLimits.getOptional("spending_limits") + + /** + * Returns the raw JSON value of [maximumAuthorizationCount]. + * + * Unlike [maximumAuthorizationCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_authorization_count") + @ExcludeMissing + fun _maximumAuthorizationCount(): JsonField = + maximumAuthorizationCount + + /** + * Returns the raw JSON value of [merchantAcceptorIdentifier]. + * + * Unlike [merchantAcceptorIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_acceptor_identifier") + @ExcludeMissing + fun _merchantAcceptorIdentifier(): JsonField = + merchantAcceptorIdentifier + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_code") + @ExcludeMissing + fun _merchantCategoryCode(): JsonField = merchantCategoryCode + + /** + * Returns the raw JSON value of [merchantCountry]. + * + * Unlike [merchantCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_country") + @ExcludeMissing + fun _merchantCountry(): JsonField = merchantCountry + + /** + * Returns the raw JSON value of [spendingLimits]. + * + * Unlike [spendingLimits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spending_limits") + @ExcludeMissing + fun _spendingLimits(): JsonField> = spendingLimits + + @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 [AuthorizationControls]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthorizationControls]. */ + class Builder internal constructor() { + + private var maximumAuthorizationCount: JsonField = + JsonMissing.of() + private var merchantAcceptorIdentifier: JsonField = + JsonMissing.of() + private var merchantCategoryCode: JsonField = JsonMissing.of() + private var merchantCountry: JsonField = JsonMissing.of() + private var spendingLimits: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authorizationControls: AuthorizationControls) = apply { + maximumAuthorizationCount = authorizationControls.maximumAuthorizationCount + merchantAcceptorIdentifier = authorizationControls.merchantAcceptorIdentifier + merchantCategoryCode = authorizationControls.merchantCategoryCode + merchantCountry = authorizationControls.merchantCountry + spendingLimits = authorizationControls.spendingLimits.map { it.toMutableList() } + additionalProperties = authorizationControls.additionalProperties.toMutableMap() + } + + /** Limits the number of authorizations that can be approved on this card. */ + fun maximumAuthorizationCount(maximumAuthorizationCount: MaximumAuthorizationCount) = + maximumAuthorizationCount(JsonField.of(maximumAuthorizationCount)) + + /** + * Sets [Builder.maximumAuthorizationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAuthorizationCount] with a well-typed + * [MaximumAuthorizationCount] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun maximumAuthorizationCount( + maximumAuthorizationCount: JsonField + ) = apply { this.maximumAuthorizationCount = maximumAuthorizationCount } + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on + * this card. + */ + fun merchantAcceptorIdentifier(merchantAcceptorIdentifier: MerchantAcceptorIdentifier) = + merchantAcceptorIdentifier(JsonField.of(merchantAcceptorIdentifier)) + + /** + * Sets [Builder.merchantAcceptorIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAcceptorIdentifier] with a well-typed + * [MerchantAcceptorIdentifier] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchantAcceptorIdentifier( + merchantAcceptorIdentifier: JsonField + ) = apply { this.merchantAcceptorIdentifier = merchantAcceptorIdentifier } + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on + * this card. + */ + fun merchantCategoryCode(merchantCategoryCode: MerchantCategoryCode) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed + * [MerchantCategoryCode] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = + apply { + this.merchantCategoryCode = merchantCategoryCode + } + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + */ + fun merchantCountry(merchantCountry: MerchantCountry) = + merchantCountry(JsonField.of(merchantCountry)) + + /** + * Sets [Builder.merchantCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCountry] with a well-typed [MerchantCountry] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun merchantCountry(merchantCountry: JsonField) = apply { + this.merchantCountry = merchantCountry + } + + /** + * Spending limits for this card. The most restrictive limit is applied if multiple + * limits match. + */ + fun spendingLimits(spendingLimits: List) = + spendingLimits(JsonField.of(spendingLimits)) + + /** + * Sets [Builder.spendingLimits] to an arbitrary JSON value. + * + * You should usually call [Builder.spendingLimits] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun spendingLimits(spendingLimits: JsonField>) = apply { + this.spendingLimits = spendingLimits.map { it.toMutableList() } + } + + /** + * Adds a single [SpendingLimit] to [spendingLimits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpendingLimit(spendingLimit: SpendingLimit) = apply { + spendingLimits = + (spendingLimits ?: JsonField.of(mutableListOf())).also { + checkKnown("spendingLimits", it).add(spendingLimit) + } + } + + 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 [AuthorizationControls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AuthorizationControls = + AuthorizationControls( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + (spendingLimits ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuthorizationControls = apply { + if (validated) { + return@apply + } + + maximumAuthorizationCount().ifPresent { it.validate() } + merchantAcceptorIdentifier().ifPresent { it.validate() } + merchantCategoryCode().ifPresent { it.validate() } + merchantCountry().ifPresent { it.validate() } + spendingLimits().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (maximumAuthorizationCount.asKnown().getOrNull()?.validity() ?: 0) + + (merchantAcceptorIdentifier.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCategoryCode.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCountry.asKnown().getOrNull()?.validity() ?: 0) + + (spendingLimits.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Limits the number of authorizations that can be approved on this card. */ + class MaximumAuthorizationCount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("all_time") + @ExcludeMissing + allTime: JsonField = JsonMissing.of() + ) : this(allTime, mutableMapOf()) + + /** + * The maximum number of authorizations that can be approved on this card over its + * lifetime. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allTime(): Long = allTime.getRequired("all_time") + + /** + * Returns the raw JSON value of [allTime]. + * + * Unlike [allTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("all_time") @ExcludeMissing fun _allTime(): JsonField = allTime + + @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 + * [MaximumAuthorizationCount]. + * + * The following fields are required: + * ```java + * .allTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumAuthorizationCount]. */ + class Builder internal constructor() { + + private var allTime: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAuthorizationCount: MaximumAuthorizationCount) = apply { + allTime = maximumAuthorizationCount.allTime + additionalProperties = + maximumAuthorizationCount.additionalProperties.toMutableMap() + } + + /** + * The maximum number of authorizations that can be approved on this card over its + * lifetime. + */ + fun allTime(allTime: Long) = allTime(JsonField.of(allTime)) + + /** + * Sets [Builder.allTime] to an arbitrary JSON value. + * + * You should usually call [Builder.allTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allTime(allTime: JsonField) = apply { this.allTime = allTime } + + 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 [MaximumAuthorizationCount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaximumAuthorizationCount = + MaximumAuthorizationCount( + checkRequired("allTime", allTime), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaximumAuthorizationCount = apply { + if (validated) { + return@apply + } + + allTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (allTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaximumAuthorizationCount && + allTime == other.allTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allTime, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumAuthorizationCount{allTime=$allTime, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on this + * card. + */ + class MerchantAcceptorIdentifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The Merchant Acceptor IDs that are allowed for authorizations on this card. + * Authorizations with Merchant Acceptor IDs not in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The Merchant Acceptor IDs that are blocked for authorizations on this card. + * Authorizations with Merchant Acceptor IDs in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 + * [MerchantAcceptorIdentifier]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantAcceptorIdentifier]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantAcceptorIdentifier: MerchantAcceptorIdentifier) = apply { + allowed = merchantAcceptorIdentifier.allowed.map { it.toMutableList() } + blocked = merchantAcceptorIdentifier.blocked.map { it.toMutableList() } + additionalProperties = + merchantAcceptorIdentifier.additionalProperties.toMutableMap() + } + + /** + * The Merchant Acceptor IDs that are allowed for authorizations on this card. + * Authorizations with Merchant Acceptor IDs not in this list will be declined. + */ + fun allowed(allowed: List) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** + * The Merchant Acceptor IDs that are blocked for authorizations on this card. + * Authorizations with Merchant Acceptor IDs in this list will be declined. + */ + fun blocked(blocked: List) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantAcceptorIdentifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantAcceptorIdentifier = + MerchantAcceptorIdentifier( + (allowed ?: JsonMissing.of()).map { it.toImmutable() }, + (blocked ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantAcceptorIdentifier = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val identifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("identifier") + @ExcludeMissing + identifier: JsonField = JsonMissing.of() + ) : this(identifier, mutableMapOf()) + + /** + * The Merchant Acceptor ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun identifier(): String = identifier.getRequired("identifier") + + /** + * Returns the raw JSON value of [identifier]. + * + * Unlike [identifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("identifier") + @ExcludeMissing + fun _identifier(): JsonField = identifier + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var identifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + identifier = allowed.identifier + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor ID. */ + fun identifier(identifier: String) = identifier(JsonField.of(identifier)) + + /** + * Sets [Builder.identifier] to an arbitrary JSON value. + * + * You should usually call [Builder.identifier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identifier(identifier: JsonField) = apply { + this.identifier = identifier + } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed( + checkRequired("identifier", identifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + identifier() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (identifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + identifier == other.identifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(identifier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{identifier=$identifier, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val identifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("identifier") + @ExcludeMissing + identifier: JsonField = JsonMissing.of() + ) : this(identifier, mutableMapOf()) + + /** + * The Merchant Acceptor ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun identifier(): String = identifier.getRequired("identifier") + + /** + * Returns the raw JSON value of [identifier]. + * + * Unlike [identifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("identifier") + @ExcludeMissing + fun _identifier(): JsonField = identifier + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var identifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + identifier = blocked.identifier + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor ID. */ + fun identifier(identifier: String) = identifier(JsonField.of(identifier)) + + /** + * Sets [Builder.identifier] to an arbitrary JSON value. + * + * You should usually call [Builder.identifier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identifier(identifier: JsonField) = apply { + this.identifier = identifier + } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked( + checkRequired("identifier", identifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + identifier() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (identifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + identifier == other.identifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(identifier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{identifier=$identifier, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantAcceptorIdentifier && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantAcceptorIdentifier{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on this + * card. + */ + class MerchantCategoryCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The Merchant Category Codes that are allowed for authorizations on this card. + * Authorizations with Merchant Category Codes not in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The Merchant Category Codes that are blocked for authorizations on this card. + * Authorizations with Merchant Category Codes in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 [MerchantCategoryCode]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCategoryCode]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCategoryCode: MerchantCategoryCode) = apply { + allowed = merchantCategoryCode.allowed.map { it.toMutableList() } + blocked = merchantCategoryCode.blocked.map { it.toMutableList() } + additionalProperties = merchantCategoryCode.additionalProperties.toMutableMap() + } + + /** + * The Merchant Category Codes that are allowed for authorizations on this card. + * Authorizations with Merchant Category Codes not in this list will be declined. + */ + fun allowed(allowed: List) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** + * The Merchant Category Codes that are blocked for authorizations on this card. + * Authorizations with Merchant Category Codes in this list will be declined. + */ + fun blocked(blocked: List) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantCategoryCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantCategoryCode = + MerchantCategoryCode( + (allowed ?: JsonMissing.of()).map { it.toImmutable() }, + (blocked ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCategoryCode = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + code = allowed.code + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed(checkRequired("code", code), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{code=$code, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + code = blocked.code + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked(checkRequired("code", code), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{code=$code, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCategoryCode && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCategoryCode{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + */ + class MerchantCountry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The merchant countries that are allowed for authorizations on this card. + * Authorizations with merchant countries not in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The merchant countries that are blocked for authorizations on this card. + * Authorizations with merchant countries in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 [MerchantCountry]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCountry]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCountry: MerchantCountry) = apply { + allowed = merchantCountry.allowed.map { it.toMutableList() } + blocked = merchantCountry.blocked.map { it.toMutableList() } + additionalProperties = merchantCountry.additionalProperties.toMutableMap() + } + + /** + * The merchant countries that are allowed for authorizations on this card. + * Authorizations with merchant countries not in this list will be declined. + */ + fun allowed(allowed: List) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** + * The merchant countries that are blocked for authorizations on this card. + * Authorizations with merchant countries in this list will be declined. + */ + fun blocked(blocked: List) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantCountry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantCountry = + MerchantCountry( + (allowed ?: JsonMissing.of()).map { it.toImmutable() }, + (blocked ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCountry = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val country: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of() + ) : this(country, mutableMapOf()) + + /** + * The ISO 3166-1 alpha-2 country code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .country() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + country = allowed.country + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The ISO 3166-1 alpha-2 country code. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .country() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed( + checkRequired("country", country), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + country() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (country.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + country == other.country && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(country, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{country=$country, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val country: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of() + ) : this(country, mutableMapOf()) + + /** + * The ISO 3166-1 alpha-2 country code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .country() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + country = blocked.country + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The ISO 3166-1 alpha-2 country code. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .country() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked( + checkRequired("country", country), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + country() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (country.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + country == other.country && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(country, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{country=$country, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCountry && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCountry{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + class SpendingLimit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val interval: JsonField, + private val settlementAmount: JsonField, + private val merchantCategoryCodes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("interval") + @ExcludeMissing + interval: JsonField = JsonMissing.of(), + @JsonProperty("settlement_amount") + @ExcludeMissing + settlementAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_codes") + @ExcludeMissing + merchantCategoryCodes: JsonField> = JsonMissing.of(), + ) : this(interval, settlementAmount, merchantCategoryCodes, mutableMapOf()) + + /** + * The interval at which the spending limit is enforced. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun interval(): Interval = interval.getRequired("interval") + + /** + * The maximum settlement amount permitted in the given interval. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun settlementAmount(): Long = settlementAmount.getRequired("settlement_amount") + + /** + * The Merchant Category Codes this spending limit applies to. If not set, the limit + * applies to all transactions. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantCategoryCodes(): Optional> = + merchantCategoryCodes.getOptional("merchant_category_codes") + + /** + * Returns the raw JSON value of [interval]. + * + * Unlike [interval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interval") + @ExcludeMissing + fun _interval(): JsonField = interval + + /** + * Returns the raw JSON value of [settlementAmount]. + * + * Unlike [settlementAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_amount") + @ExcludeMissing + fun _settlementAmount(): JsonField = settlementAmount + + /** + * Returns the raw JSON value of [merchantCategoryCodes]. + * + * Unlike [merchantCategoryCodes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_codes") + @ExcludeMissing + fun _merchantCategoryCodes(): JsonField> = + merchantCategoryCodes + + @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 [SpendingLimit]. + * + * The following fields are required: + * ```java + * .interval() + * .settlementAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpendingLimit]. */ + class Builder internal constructor() { + + private var interval: JsonField? = null + private var settlementAmount: JsonField? = null + private var merchantCategoryCodes: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spendingLimit: SpendingLimit) = apply { + interval = spendingLimit.interval + settlementAmount = spendingLimit.settlementAmount + merchantCategoryCodes = + spendingLimit.merchantCategoryCodes.map { it.toMutableList() } + additionalProperties = spendingLimit.additionalProperties.toMutableMap() + } + + /** The interval at which the spending limit is enforced. */ + fun interval(interval: Interval) = interval(JsonField.of(interval)) + + /** + * Sets [Builder.interval] to an arbitrary JSON value. + * + * You should usually call [Builder.interval] with a well-typed [Interval] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun interval(interval: JsonField) = apply { this.interval = interval } + + /** The maximum settlement amount permitted in the given interval. */ + fun settlementAmount(settlementAmount: Long) = + settlementAmount(JsonField.of(settlementAmount)) + + /** + * Sets [Builder.settlementAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun settlementAmount(settlementAmount: JsonField) = apply { + this.settlementAmount = settlementAmount + } + + /** + * The Merchant Category Codes this spending limit applies to. If not set, the limit + * applies to all transactions. + */ + fun merchantCategoryCodes(merchantCategoryCodes: List) = + merchantCategoryCodes(JsonField.of(merchantCategoryCodes)) + + /** + * Sets [Builder.merchantCategoryCodes] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCodes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantCategoryCodes( + merchantCategoryCodes: JsonField> + ) = apply { + this.merchantCategoryCodes = merchantCategoryCodes.map { it.toMutableList() } + } + + /** + * Adds a single [MerchantCategoryCode] to [merchantCategoryCodes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMerchantCategoryCode(merchantCategoryCode: MerchantCategoryCode) = apply { + merchantCategoryCodes = + (merchantCategoryCodes ?: JsonField.of(mutableListOf())).also { + checkKnown("merchantCategoryCodes", it).add(merchantCategoryCode) + } + } + + 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 [SpendingLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .interval() + * .settlementAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendingLimit = + SpendingLimit( + checkRequired("interval", interval), + checkRequired("settlementAmount", settlementAmount), + (merchantCategoryCodes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SpendingLimit = apply { + if (validated) { + return@apply + } + + interval().validate() + settlementAmount() + merchantCategoryCodes().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (interval.asKnown().getOrNull()?.validity() ?: 0) + + (if (settlementAmount.asKnown().isPresent) 1 else 0) + + (merchantCategoryCodes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** The interval at which the spending limit is enforced. */ + class Interval @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 { + + /** The spending limit applies over the lifetime of the card. */ + @JvmField val ALL_TIME = of("all_time") + + /** The spending limit applies per transaction. */ + @JvmField val PER_TRANSACTION = of("per_transaction") + + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + @JvmField val PER_DAY = of("per_day") + + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + @JvmField val PER_WEEK = of("per_week") + + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + @JvmField val PER_MONTH = of("per_month") + + @JvmStatic fun of(value: String) = Interval(JsonField.of(value)) + } + + /** An enum containing [Interval]'s known values. */ + enum class Known { + /** The spending limit applies over the lifetime of the card. */ + ALL_TIME, + /** The spending limit applies per transaction. */ + PER_TRANSACTION, + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + PER_DAY, + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + PER_WEEK, + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + PER_MONTH, + } + + /** + * An enum containing [Interval]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Interval] 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 { + /** The spending limit applies over the lifetime of the card. */ + ALL_TIME, + /** The spending limit applies per transaction. */ + PER_TRANSACTION, + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + PER_DAY, + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + PER_WEEK, + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + PER_MONTH, + /** + * An enum member indicating that [Interval] 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) { + ALL_TIME -> Value.ALL_TIME + PER_TRANSACTION -> Value.PER_TRANSACTION + PER_DAY -> Value.PER_DAY + PER_WEEK -> Value.PER_WEEK + PER_MONTH -> Value.PER_MONTH + 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 IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ALL_TIME -> Known.ALL_TIME + PER_TRANSACTION -> Known.PER_TRANSACTION + PER_DAY -> Known.PER_DAY + PER_WEEK -> Known.PER_WEEK + PER_MONTH -> Known.PER_MONTH + else -> throw IncreaseInvalidDataException("Unknown Interval: $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 IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Interval = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 other is Interval && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MerchantCategoryCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 + * [MerchantCategoryCode]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCategoryCode]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCategoryCode: MerchantCategoryCode) = apply { + code = merchantCategoryCode.code + additionalProperties = + merchantCategoryCode.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [MerchantCategoryCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCategoryCode = + MerchantCategoryCode( + checkRequired("code", code), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCategoryCode = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCategoryCode && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCategoryCode{code=$code, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendingLimit && + interval == other.interval && + settlementAmount == other.settlementAmount && + merchantCategoryCodes == other.merchantCategoryCodes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + interval, + settlementAmount, + merchantCategoryCodes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpendingLimit{interval=$interval, settlementAmount=$settlementAmount, merchantCategoryCodes=$merchantCategoryCodes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthorizationControls && + maximumAuthorizationCount == other.maximumAuthorizationCount && + merchantAcceptorIdentifier == other.merchantAcceptorIdentifier && + merchantCategoryCode == other.merchantCategoryCode && + merchantCountry == other.merchantCountry && + spendingLimits == other.spendingLimits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + spendingLimits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthorizationControls{maximumAuthorizationCount=$maximumAuthorizationCount, merchantAcceptorIdentifier=$merchantAcceptorIdentifier, merchantCategoryCode=$merchantCategoryCode, merchantCountry=$merchantCountry, spendingLimits=$spendingLimits, additionalProperties=$additionalProperties}" } /** The card's billing address. */ diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardUpdateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardUpdateParams.kt index b3d0b11dd..40999e205 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardUpdateParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cards/CardUpdateParams.kt @@ -12,9 +12,11 @@ import com.increase.api.core.JsonField import com.increase.api.core.JsonMissing import com.increase.api.core.JsonValue import com.increase.api.core.Params +import com.increase.api.core.checkKnown import com.increase.api.core.checkRequired import com.increase.api.core.http.Headers import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable import com.increase.api.errors.IncreaseInvalidDataException import java.util.Collections import java.util.Objects @@ -33,6 +35,14 @@ private constructor( /** The card identifier. */ fun cardId(): Optional = Optional.ofNullable(cardId) + /** + * Controls that restrict how this card can be used. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authorizationControls(): Optional = body.authorizationControls() + /** * The card's updated billing address. * @@ -75,6 +85,14 @@ private constructor( */ fun status(): Optional = body.status() + /** + * Returns the raw JSON value of [authorizationControls]. + * + * Unlike [authorizationControls], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _authorizationControls(): JsonField = body._authorizationControls() + /** * Returns the raw JSON value of [billingAddress]. * @@ -155,15 +173,31 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [authorizationControls] * - [billingAddress] * - [description] * - [digitalWallet] * - [entityId] - * - [status] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Controls that restrict how this card can be used. */ + fun authorizationControls(authorizationControls: AuthorizationControls) = apply { + body.authorizationControls(authorizationControls) + } + + /** + * Sets [Builder.authorizationControls] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationControls] with a well-typed + * [AuthorizationControls] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authorizationControls(authorizationControls: JsonField) = apply { + body.authorizationControls(authorizationControls) + } + /** The card's updated billing address. */ fun billingAddress(billingAddress: BillingAddress) = apply { body.billingAddress(billingAddress) @@ -382,6 +416,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val authorizationControls: JsonField, private val billingAddress: JsonField, private val description: JsonField, private val digitalWallet: JsonField, @@ -392,6 +427,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("authorization_controls") + @ExcludeMissing + authorizationControls: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing billingAddress: JsonField = JsonMissing.of(), @@ -405,7 +443,24 @@ private constructor( @ExcludeMissing entityId: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(billingAddress, description, digitalWallet, entityId, status, mutableMapOf()) + ) : this( + authorizationControls, + billingAddress, + description, + digitalWallet, + entityId, + status, + mutableMapOf(), + ) + + /** + * Controls that restrict how this card can be used. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun authorizationControls(): Optional = + authorizationControls.getOptional("authorization_controls") /** * The card's updated billing address. @@ -450,6 +505,16 @@ private constructor( */ fun status(): Optional = status.getOptional("status") + /** + * Returns the raw JSON value of [authorizationControls]. + * + * Unlike [authorizationControls], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authorization_controls") + @ExcludeMissing + fun _authorizationControls(): JsonField = authorizationControls + /** * Returns the raw JSON value of [billingAddress]. * @@ -514,6 +579,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var authorizationControls: JsonField = JsonMissing.of() private var billingAddress: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var digitalWallet: JsonField = JsonMissing.of() @@ -523,6 +589,7 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + authorizationControls = body.authorizationControls billingAddress = body.billingAddress description = body.description digitalWallet = body.digitalWallet @@ -531,6 +598,22 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Controls that restrict how this card can be used. */ + fun authorizationControls(authorizationControls: AuthorizationControls) = + authorizationControls(JsonField.of(authorizationControls)) + + /** + * Sets [Builder.authorizationControls] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationControls] with a well-typed + * [AuthorizationControls] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun authorizationControls(authorizationControls: JsonField) = + apply { + this.authorizationControls = authorizationControls + } + /** The card's updated billing address. */ fun billingAddress(billingAddress: BillingAddress) = billingAddress(JsonField.of(billingAddress)) @@ -631,6 +714,7 @@ private constructor( */ fun build(): Body = Body( + authorizationControls, billingAddress, description, digitalWallet, @@ -647,6 +731,7 @@ private constructor( return@apply } + authorizationControls().ifPresent { it.validate() } billingAddress().ifPresent { it.validate() } description() digitalWallet().ifPresent { it.validate() } @@ -671,7 +756,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (authorizationControls.asKnown().getOrNull()?.validity() ?: 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (digitalWallet.asKnown().getOrNull()?.validity() ?: 0) + (if (entityId.asKnown().isPresent) 1 else 0) + @@ -683,6 +769,7 @@ private constructor( } return other is Body && + authorizationControls == other.authorizationControls && billingAddress == other.billingAddress && description == other.description && digitalWallet == other.digitalWallet && @@ -693,6 +780,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + authorizationControls, billingAddress, description, digitalWallet, @@ -705,7 +793,2913 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{billingAddress=$billingAddress, description=$description, digitalWallet=$digitalWallet, entityId=$entityId, status=$status, additionalProperties=$additionalProperties}" + "Body{authorizationControls=$authorizationControls, billingAddress=$billingAddress, description=$description, digitalWallet=$digitalWallet, entityId=$entityId, status=$status, additionalProperties=$additionalProperties}" + } + + /** Controls that restrict how this card can be used. */ + class AuthorizationControls + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val maximumAuthorizationCount: JsonField, + private val merchantAcceptorIdentifier: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCountry: JsonField, + private val spendingLimits: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maximum_authorization_count") + @ExcludeMissing + maximumAuthorizationCount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_identifier") + @ExcludeMissing + merchantAcceptorIdentifier: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_country") + @ExcludeMissing + merchantCountry: JsonField = JsonMissing.of(), + @JsonProperty("spending_limits") + @ExcludeMissing + spendingLimits: JsonField> = JsonMissing.of(), + ) : this( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + spendingLimits, + mutableMapOf(), + ) + + /** + * Limits the number of authorizations that can be approved on this card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maximumAuthorizationCount(): Optional = + maximumAuthorizationCount.getOptional("maximum_authorization_count") + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantAcceptorIdentifier(): Optional = + merchantAcceptorIdentifier.getOptional("merchant_acceptor_identifier") + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCategoryCode(): Optional = + merchantCategoryCode.getOptional("merchant_category_code") + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCountry(): Optional = + merchantCountry.getOptional("merchant_country") + + /** + * Spending limits for this card. The most restrictive limit is applied if multiple limits + * match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun spendingLimits(): Optional> = + spendingLimits.getOptional("spending_limits") + + /** + * Returns the raw JSON value of [maximumAuthorizationCount]. + * + * Unlike [maximumAuthorizationCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_authorization_count") + @ExcludeMissing + fun _maximumAuthorizationCount(): JsonField = + maximumAuthorizationCount + + /** + * Returns the raw JSON value of [merchantAcceptorIdentifier]. + * + * Unlike [merchantAcceptorIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_acceptor_identifier") + @ExcludeMissing + fun _merchantAcceptorIdentifier(): JsonField = + merchantAcceptorIdentifier + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_code") + @ExcludeMissing + fun _merchantCategoryCode(): JsonField = merchantCategoryCode + + /** + * Returns the raw JSON value of [merchantCountry]. + * + * Unlike [merchantCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_country") + @ExcludeMissing + fun _merchantCountry(): JsonField = merchantCountry + + /** + * Returns the raw JSON value of [spendingLimits]. + * + * Unlike [spendingLimits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("spending_limits") + @ExcludeMissing + fun _spendingLimits(): JsonField> = spendingLimits + + @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 [AuthorizationControls]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthorizationControls]. */ + class Builder internal constructor() { + + private var maximumAuthorizationCount: JsonField = + JsonMissing.of() + private var merchantAcceptorIdentifier: JsonField = + JsonMissing.of() + private var merchantCategoryCode: JsonField = JsonMissing.of() + private var merchantCountry: JsonField = JsonMissing.of() + private var spendingLimits: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authorizationControls: AuthorizationControls) = apply { + maximumAuthorizationCount = authorizationControls.maximumAuthorizationCount + merchantAcceptorIdentifier = authorizationControls.merchantAcceptorIdentifier + merchantCategoryCode = authorizationControls.merchantCategoryCode + merchantCountry = authorizationControls.merchantCountry + spendingLimits = authorizationControls.spendingLimits.map { it.toMutableList() } + additionalProperties = authorizationControls.additionalProperties.toMutableMap() + } + + /** Limits the number of authorizations that can be approved on this card. */ + fun maximumAuthorizationCount(maximumAuthorizationCount: MaximumAuthorizationCount) = + maximumAuthorizationCount(JsonField.of(maximumAuthorizationCount)) + + /** + * Sets [Builder.maximumAuthorizationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAuthorizationCount] with a well-typed + * [MaximumAuthorizationCount] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun maximumAuthorizationCount( + maximumAuthorizationCount: JsonField + ) = apply { this.maximumAuthorizationCount = maximumAuthorizationCount } + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on + * this card. + */ + fun merchantAcceptorIdentifier(merchantAcceptorIdentifier: MerchantAcceptorIdentifier) = + merchantAcceptorIdentifier(JsonField.of(merchantAcceptorIdentifier)) + + /** + * Sets [Builder.merchantAcceptorIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAcceptorIdentifier] with a well-typed + * [MerchantAcceptorIdentifier] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchantAcceptorIdentifier( + merchantAcceptorIdentifier: JsonField + ) = apply { this.merchantAcceptorIdentifier = merchantAcceptorIdentifier } + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on + * this card. + */ + fun merchantCategoryCode(merchantCategoryCode: MerchantCategoryCode) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed + * [MerchantCategoryCode] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = + apply { + this.merchantCategoryCode = merchantCategoryCode + } + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + */ + fun merchantCountry(merchantCountry: MerchantCountry) = + merchantCountry(JsonField.of(merchantCountry)) + + /** + * Sets [Builder.merchantCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCountry] with a well-typed [MerchantCountry] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun merchantCountry(merchantCountry: JsonField) = apply { + this.merchantCountry = merchantCountry + } + + /** + * Spending limits for this card. The most restrictive limit is applied if multiple + * limits match. + */ + fun spendingLimits(spendingLimits: List) = + spendingLimits(JsonField.of(spendingLimits)) + + /** + * Sets [Builder.spendingLimits] to an arbitrary JSON value. + * + * You should usually call [Builder.spendingLimits] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun spendingLimits(spendingLimits: JsonField>) = apply { + this.spendingLimits = spendingLimits.map { it.toMutableList() } + } + + /** + * Adds a single [SpendingLimit] to [spendingLimits]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSpendingLimit(spendingLimit: SpendingLimit) = apply { + spendingLimits = + (spendingLimits ?: JsonField.of(mutableListOf())).also { + checkKnown("spendingLimits", it).add(spendingLimit) + } + } + + 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 [AuthorizationControls]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AuthorizationControls = + AuthorizationControls( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + (spendingLimits ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuthorizationControls = apply { + if (validated) { + return@apply + } + + maximumAuthorizationCount().ifPresent { it.validate() } + merchantAcceptorIdentifier().ifPresent { it.validate() } + merchantCategoryCode().ifPresent { it.validate() } + merchantCountry().ifPresent { it.validate() } + spendingLimits().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (maximumAuthorizationCount.asKnown().getOrNull()?.validity() ?: 0) + + (merchantAcceptorIdentifier.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCategoryCode.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCountry.asKnown().getOrNull()?.validity() ?: 0) + + (spendingLimits.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Limits the number of authorizations that can be approved on this card. */ + class MaximumAuthorizationCount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("all_time") + @ExcludeMissing + allTime: JsonField = JsonMissing.of() + ) : this(allTime, mutableMapOf()) + + /** + * The maximum number of authorizations that can be approved on this card over its + * lifetime. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allTime(): Long = allTime.getRequired("all_time") + + /** + * Returns the raw JSON value of [allTime]. + * + * Unlike [allTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("all_time") @ExcludeMissing fun _allTime(): JsonField = allTime + + @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 + * [MaximumAuthorizationCount]. + * + * The following fields are required: + * ```java + * .allTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumAuthorizationCount]. */ + class Builder internal constructor() { + + private var allTime: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAuthorizationCount: MaximumAuthorizationCount) = apply { + allTime = maximumAuthorizationCount.allTime + additionalProperties = + maximumAuthorizationCount.additionalProperties.toMutableMap() + } + + /** + * The maximum number of authorizations that can be approved on this card over its + * lifetime. + */ + fun allTime(allTime: Long) = allTime(JsonField.of(allTime)) + + /** + * Sets [Builder.allTime] to an arbitrary JSON value. + * + * You should usually call [Builder.allTime] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allTime(allTime: JsonField) = apply { this.allTime = allTime } + + 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 [MaximumAuthorizationCount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaximumAuthorizationCount = + MaximumAuthorizationCount( + checkRequired("allTime", allTime), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaximumAuthorizationCount = apply { + if (validated) { + return@apply + } + + allTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (allTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaximumAuthorizationCount && + allTime == other.allTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allTime, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumAuthorizationCount{allTime=$allTime, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which Merchant Acceptor IDs are allowed or blocked for authorizations on this + * card. + */ + class MerchantAcceptorIdentifier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The Merchant Acceptor IDs that are allowed for authorizations on this card. + * Authorizations with Merchant Acceptor IDs not in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The Merchant Acceptor IDs that are blocked for authorizations on this card. + * Authorizations with Merchant Acceptor IDs in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 + * [MerchantAcceptorIdentifier]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantAcceptorIdentifier]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantAcceptorIdentifier: MerchantAcceptorIdentifier) = apply { + allowed = merchantAcceptorIdentifier.allowed.map { it.toMutableList() } + blocked = merchantAcceptorIdentifier.blocked.map { it.toMutableList() } + additionalProperties = + merchantAcceptorIdentifier.additionalProperties.toMutableMap() + } + + /** + * The Merchant Acceptor IDs that are allowed for authorizations on this card. + * Authorizations with Merchant Acceptor IDs not in this list will be declined. + */ + fun allowed(allowed: List) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** + * The Merchant Acceptor IDs that are blocked for authorizations on this card. + * Authorizations with Merchant Acceptor IDs in this list will be declined. + */ + fun blocked(blocked: List) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantAcceptorIdentifier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantAcceptorIdentifier = + MerchantAcceptorIdentifier( + (allowed ?: JsonMissing.of()).map { it.toImmutable() }, + (blocked ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantAcceptorIdentifier = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val identifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("identifier") + @ExcludeMissing + identifier: JsonField = JsonMissing.of() + ) : this(identifier, mutableMapOf()) + + /** + * The Merchant Acceptor ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun identifier(): String = identifier.getRequired("identifier") + + /** + * Returns the raw JSON value of [identifier]. + * + * Unlike [identifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("identifier") + @ExcludeMissing + fun _identifier(): JsonField = identifier + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var identifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + identifier = allowed.identifier + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor ID. */ + fun identifier(identifier: String) = identifier(JsonField.of(identifier)) + + /** + * Sets [Builder.identifier] to an arbitrary JSON value. + * + * You should usually call [Builder.identifier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identifier(identifier: JsonField) = apply { + this.identifier = identifier + } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed( + checkRequired("identifier", identifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + identifier() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (identifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + identifier == other.identifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(identifier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{identifier=$identifier, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val identifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("identifier") + @ExcludeMissing + identifier: JsonField = JsonMissing.of() + ) : this(identifier, mutableMapOf()) + + /** + * The Merchant Acceptor ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun identifier(): String = identifier.getRequired("identifier") + + /** + * Returns the raw JSON value of [identifier]. + * + * Unlike [identifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("identifier") + @ExcludeMissing + fun _identifier(): JsonField = identifier + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var identifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + identifier = blocked.identifier + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The Merchant Acceptor ID. */ + fun identifier(identifier: String) = identifier(JsonField.of(identifier)) + + /** + * Sets [Builder.identifier] to an arbitrary JSON value. + * + * You should usually call [Builder.identifier] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identifier(identifier: JsonField) = apply { + this.identifier = identifier + } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .identifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked( + checkRequired("identifier", identifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + identifier() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (identifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + identifier == other.identifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(identifier, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{identifier=$identifier, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantAcceptorIdentifier && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantAcceptorIdentifier{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which Merchant Category Codes are allowed or blocked for authorizations on this + * card. + */ + class MerchantCategoryCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The Merchant Category Codes that are allowed for authorizations on this card. + * Authorizations with Merchant Category Codes not in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The Merchant Category Codes that are blocked for authorizations on this card. + * Authorizations with Merchant Category Codes in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 [MerchantCategoryCode]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCategoryCode]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCategoryCode: MerchantCategoryCode) = apply { + allowed = merchantCategoryCode.allowed.map { it.toMutableList() } + blocked = merchantCategoryCode.blocked.map { it.toMutableList() } + additionalProperties = merchantCategoryCode.additionalProperties.toMutableMap() + } + + /** + * The Merchant Category Codes that are allowed for authorizations on this card. + * Authorizations with Merchant Category Codes not in this list will be declined. + */ + fun allowed(allowed: List) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** + * The Merchant Category Codes that are blocked for authorizations on this card. + * Authorizations with Merchant Category Codes in this list will be declined. + */ + fun blocked(blocked: List) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantCategoryCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantCategoryCode = + MerchantCategoryCode( + (allowed ?: JsonMissing.of()).map { it.toImmutable() }, + (blocked ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCategoryCode = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + code = allowed.code + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed(checkRequired("code", code), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{code=$code, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + code = blocked.code + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked(checkRequired("code", code), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{code=$code, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCategoryCode && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCategoryCode{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + /** + * Restricts which merchant countries are allowed or blocked for authorizations on this + * card. + */ + class MerchantCountry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField>, + private val blocked: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField> = JsonMissing.of(), + @JsonProperty("blocked") + @ExcludeMissing + blocked: JsonField> = JsonMissing.of(), + ) : this(allowed, blocked, mutableMapOf()) + + /** + * The merchant countries that are allowed for authorizations on this card. + * Authorizations with merchant countries not in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowed(): Optional> = allowed.getOptional("allowed") + + /** + * The merchant countries that are blocked for authorizations on this card. + * Authorizations with merchant countries in this list will be declined. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun blocked(): Optional> = blocked.getOptional("blocked") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") + @ExcludeMissing + fun _allowed(): JsonField> = allowed + + /** + * Returns the raw JSON value of [blocked]. + * + * Unlike [blocked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocked") + @ExcludeMissing + fun _blocked(): JsonField> = blocked + + @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 [MerchantCountry]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCountry]. */ + class Builder internal constructor() { + + private var allowed: JsonField>? = null + private var blocked: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCountry: MerchantCountry) = apply { + allowed = merchantCountry.allowed.map { it.toMutableList() } + blocked = merchantCountry.blocked.map { it.toMutableList() } + additionalProperties = merchantCountry.additionalProperties.toMutableMap() + } + + /** + * The merchant countries that are allowed for authorizations on this card. + * Authorizations with merchant countries not in this list will be declined. + */ + fun allowed(allowed: List) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField>) = apply { + this.allowed = allowed.map { it.toMutableList() } + } + + /** + * Adds a single [Allowed] to [Builder.allowed]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowed(allowed: Allowed) = apply { + this.allowed = + (this.allowed ?: JsonField.of(mutableListOf())).also { + checkKnown("allowed", it).add(allowed) + } + } + + /** + * The merchant countries that are blocked for authorizations on this card. + * Authorizations with merchant countries in this list will be declined. + */ + fun blocked(blocked: List) = blocked(JsonField.of(blocked)) + + /** + * Sets [Builder.blocked] to an arbitrary JSON value. + * + * You should usually call [Builder.blocked] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocked(blocked: JsonField>) = apply { + this.blocked = blocked.map { it.toMutableList() } + } + + /** + * Adds a single [Blocked] to [Builder.blocked]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlocked(blocked: Blocked) = apply { + this.blocked = + (this.blocked ?: JsonField.of(mutableListOf())).also { + checkKnown("blocked", it).add(blocked) + } + } + + 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 [MerchantCountry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantCountry = + MerchantCountry( + (allowed ?: JsonMissing.of()).map { it.toImmutable() }, + (blocked ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCountry = apply { + if (validated) { + return@apply + } + + allowed().ifPresent { it.forEach { it.validate() } } + blocked().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (allowed.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (blocked.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Allowed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val country: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of() + ) : this(country, mutableMapOf()) + + /** + * The ISO 3166-1 alpha-2 country code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @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 [Allowed]. + * + * The following fields are required: + * ```java + * .country() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowed]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowed: Allowed) = apply { + country = allowed.country + additionalProperties = allowed.additionalProperties.toMutableMap() + } + + /** The ISO 3166-1 alpha-2 country code. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + 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 [Allowed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .country() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Allowed = + Allowed( + checkRequired("country", country), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowed = apply { + if (validated) { + return@apply + } + + country() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (country.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowed && + country == other.country && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(country, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowed{country=$country, additionalProperties=$additionalProperties}" + } + + class Blocked + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val country: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of() + ) : this(country, mutableMapOf()) + + /** + * The ISO 3166-1 alpha-2 country code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @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 [Blocked]. + * + * The following fields are required: + * ```java + * .country() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Blocked]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(blocked: Blocked) = apply { + country = blocked.country + additionalProperties = blocked.additionalProperties.toMutableMap() + } + + /** The ISO 3166-1 alpha-2 country code. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + 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 [Blocked]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .country() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Blocked = + Blocked( + checkRequired("country", country), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Blocked = apply { + if (validated) { + return@apply + } + + country() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 (country.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Blocked && + country == other.country && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(country, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Blocked{country=$country, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCountry && + allowed == other.allowed && + blocked == other.blocked && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowed, blocked, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCountry{allowed=$allowed, blocked=$blocked, additionalProperties=$additionalProperties}" + } + + class SpendingLimit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val interval: JsonField, + private val settlementAmount: JsonField, + private val merchantCategoryCodes: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("interval") + @ExcludeMissing + interval: JsonField = JsonMissing.of(), + @JsonProperty("settlement_amount") + @ExcludeMissing + settlementAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_codes") + @ExcludeMissing + merchantCategoryCodes: JsonField> = JsonMissing.of(), + ) : this(interval, settlementAmount, merchantCategoryCodes, mutableMapOf()) + + /** + * The interval at which the spending limit is enforced. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun interval(): Interval = interval.getRequired("interval") + + /** + * The maximum settlement amount permitted in the given interval. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun settlementAmount(): Long = settlementAmount.getRequired("settlement_amount") + + /** + * The Merchant Category Codes this spending limit applies to. If not set, the limit + * applies to all transactions. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantCategoryCodes(): Optional> = + merchantCategoryCodes.getOptional("merchant_category_codes") + + /** + * Returns the raw JSON value of [interval]. + * + * Unlike [interval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interval") + @ExcludeMissing + fun _interval(): JsonField = interval + + /** + * Returns the raw JSON value of [settlementAmount]. + * + * Unlike [settlementAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_amount") + @ExcludeMissing + fun _settlementAmount(): JsonField = settlementAmount + + /** + * Returns the raw JSON value of [merchantCategoryCodes]. + * + * Unlike [merchantCategoryCodes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_codes") + @ExcludeMissing + fun _merchantCategoryCodes(): JsonField> = + merchantCategoryCodes + + @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 [SpendingLimit]. + * + * The following fields are required: + * ```java + * .interval() + * .settlementAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpendingLimit]. */ + class Builder internal constructor() { + + private var interval: JsonField? = null + private var settlementAmount: JsonField? = null + private var merchantCategoryCodes: JsonField>? = + null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spendingLimit: SpendingLimit) = apply { + interval = spendingLimit.interval + settlementAmount = spendingLimit.settlementAmount + merchantCategoryCodes = + spendingLimit.merchantCategoryCodes.map { it.toMutableList() } + additionalProperties = spendingLimit.additionalProperties.toMutableMap() + } + + /** The interval at which the spending limit is enforced. */ + fun interval(interval: Interval) = interval(JsonField.of(interval)) + + /** + * Sets [Builder.interval] to an arbitrary JSON value. + * + * You should usually call [Builder.interval] with a well-typed [Interval] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun interval(interval: JsonField) = apply { this.interval = interval } + + /** The maximum settlement amount permitted in the given interval. */ + fun settlementAmount(settlementAmount: Long) = + settlementAmount(JsonField.of(settlementAmount)) + + /** + * Sets [Builder.settlementAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun settlementAmount(settlementAmount: JsonField) = apply { + this.settlementAmount = settlementAmount + } + + /** + * The Merchant Category Codes this spending limit applies to. If not set, the limit + * applies to all transactions. + */ + fun merchantCategoryCodes(merchantCategoryCodes: List) = + merchantCategoryCodes(JsonField.of(merchantCategoryCodes)) + + /** + * Sets [Builder.merchantCategoryCodes] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCodes] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantCategoryCodes( + merchantCategoryCodes: JsonField> + ) = apply { + this.merchantCategoryCodes = merchantCategoryCodes.map { it.toMutableList() } + } + + /** + * Adds a single [MerchantCategoryCode] to [merchantCategoryCodes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMerchantCategoryCode(merchantCategoryCode: MerchantCategoryCode) = apply { + merchantCategoryCodes = + (merchantCategoryCodes ?: JsonField.of(mutableListOf())).also { + checkKnown("merchantCategoryCodes", it).add(merchantCategoryCode) + } + } + + 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 [SpendingLimit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .interval() + * .settlementAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendingLimit = + SpendingLimit( + checkRequired("interval", interval), + checkRequired("settlementAmount", settlementAmount), + (merchantCategoryCodes ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SpendingLimit = apply { + if (validated) { + return@apply + } + + interval().validate() + settlementAmount() + merchantCategoryCodes().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 = + (interval.asKnown().getOrNull()?.validity() ?: 0) + + (if (settlementAmount.asKnown().isPresent) 1 else 0) + + (merchantCategoryCodes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** The interval at which the spending limit is enforced. */ + class Interval @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 { + + /** The spending limit applies over the lifetime of the card. */ + @JvmField val ALL_TIME = of("all_time") + + /** The spending limit applies per transaction. */ + @JvmField val PER_TRANSACTION = of("per_transaction") + + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + @JvmField val PER_DAY = of("per_day") + + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + @JvmField val PER_WEEK = of("per_week") + + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + @JvmField val PER_MONTH = of("per_month") + + @JvmStatic fun of(value: String) = Interval(JsonField.of(value)) + } + + /** An enum containing [Interval]'s known values. */ + enum class Known { + /** The spending limit applies over the lifetime of the card. */ + ALL_TIME, + /** The spending limit applies per transaction. */ + PER_TRANSACTION, + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + PER_DAY, + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + PER_WEEK, + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + PER_MONTH, + } + + /** + * An enum containing [Interval]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Interval] 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 { + /** The spending limit applies over the lifetime of the card. */ + ALL_TIME, + /** The spending limit applies per transaction. */ + PER_TRANSACTION, + /** The spending limit applies per day. Resets nightly at midnight UTC. */ + PER_DAY, + /** + * The spending limit applies per week. Resets weekly on Mondays at midnight + * UTC. + */ + PER_WEEK, + /** + * The spending limit applies per month. Resets on the first of the month, + * midnight UTC. + */ + PER_MONTH, + /** + * An enum member indicating that [Interval] 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) { + ALL_TIME -> Value.ALL_TIME + PER_TRANSACTION -> Value.PER_TRANSACTION + PER_DAY -> Value.PER_DAY + PER_WEEK -> Value.PER_WEEK + PER_MONTH -> Value.PER_MONTH + 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 IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ALL_TIME -> Known.ALL_TIME + PER_TRANSACTION -> Known.PER_TRANSACTION + PER_DAY -> Known.PER_DAY + PER_WEEK -> Known.PER_WEEK + PER_MONTH -> Known.PER_MONTH + else -> throw IncreaseInvalidDataException("Unknown Interval: $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 IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Interval = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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 other is Interval && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MerchantCategoryCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of() + ) : this(code, mutableMapOf()) + + /** + * The Merchant Category Code. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun code(): String = code.getRequired("code") + + /** + * 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 + + @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 + * [MerchantCategoryCode]. + * + * The following fields are required: + * ```java + * .code() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCategoryCode]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCategoryCode: MerchantCategoryCode) = apply { + code = merchantCategoryCode.code + additionalProperties = + merchantCategoryCode.additionalProperties.toMutableMap() + } + + /** The Merchant Category Code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] 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 } + + 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 [MerchantCategoryCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCategoryCode = + MerchantCategoryCode( + checkRequired("code", code), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCategoryCode = apply { + if (validated) { + return@apply + } + + code() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCategoryCode && + code == other.code && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(code, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCategoryCode{code=$code, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendingLimit && + interval == other.interval && + settlementAmount == other.settlementAmount && + merchantCategoryCodes == other.merchantCategoryCodes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + interval, + settlementAmount, + merchantCategoryCodes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpendingLimit{interval=$interval, settlementAmount=$settlementAmount, merchantCategoryCodes=$merchantCategoryCodes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthorizationControls && + maximumAuthorizationCount == other.maximumAuthorizationCount && + merchantAcceptorIdentifier == other.merchantAcceptorIdentifier && + merchantCategoryCode == other.merchantCategoryCode && + merchantCountry == other.merchantCountry && + spendingLimits == other.spendingLimits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + maximumAuthorizationCount, + merchantAcceptorIdentifier, + merchantCategoryCode, + merchantCountry, + spendingLimits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthorizationControls{maximumAuthorizationCount=$maximumAuthorizationCount, merchantAcceptorIdentifier=$merchantAcceptorIdentifier, merchantCategoryCode=$merchantCategoryCode, merchantCountry=$merchantCountry, spendingLimits=$spendingLimits, additionalProperties=$additionalProperties}" } /** The card's updated billing address. */ diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardCreateParamsTest.kt index ff594e04b..ffee8b784 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardCreateParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardCreateParamsTest.kt @@ -11,6 +11,81 @@ internal class CardCreateParamsTest { fun create() { CardCreateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + CardCreateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardCreateParams.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardCreateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardCreateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardCreateParams.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardCreateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardCreateParams.BillingAddress.builder() .city("x") @@ -37,6 +112,87 @@ internal class CardCreateParamsTest { val params = CardCreateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + CardCreateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardCreateParams.AuthorizationControls.MaximumAuthorizationCount + .builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .builder() + .addAllowed( + CardCreateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardCreateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardCreateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardCreateParams.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardCreateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardCreateParams.BillingAddress.builder() .city("x") @@ -60,6 +216,82 @@ internal class CardCreateParamsTest { val body = params._body() assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(body.authorizationControls()) + .contains( + CardCreateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardCreateParams.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardCreateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardCreateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardCreateParams.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardCreateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) assertThat(body.billingAddress()) .contains( CardCreateParams.BillingAddress.builder() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardListPageResponseTest.kt index 29223dc47..d33deb8d1 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardListPageResponseTest.kt @@ -18,6 +18,81 @@ internal class CardListPageResponseTest { Card.builder() .id("card_oubs0hwk5rn6knuecxg2") .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + Card.AuthorizationControls.builder() + .maximumAuthorizationCount( + Card.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + Card.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + Card.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("identifier") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("identifier") + .build() + ) + .build() + ) + .merchantCategoryCode( + Card.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("code") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("code") + .build() + ) + .build() + ) + .merchantCountry( + Card.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("country") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("country") + .build() + ) + .build() + ) + .addSpendingLimit( + Card.AuthorizationControls.SpendingLimit.builder() + .interval( + Card.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .addMerchantCategoryCode( + Card.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("code") + .build() + ) + .settlementAmount(0L) + .build() + ) + .build() + ) .billingAddress( Card.BillingAddress.builder() .city("New York") @@ -53,6 +128,78 @@ internal class CardListPageResponseTest { Card.builder() .id("card_oubs0hwk5rn6knuecxg2") .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + Card.AuthorizationControls.builder() + .maximumAuthorizationCount( + Card.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + Card.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + Card.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("identifier") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("identifier") + .build() + ) + .build() + ) + .merchantCategoryCode( + Card.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("code") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("code") + .build() + ) + .build() + ) + .merchantCountry( + Card.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCountry.Allowed.builder() + .country("country") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCountry.Blocked.builder() + .country("country") + .build() + ) + .build() + ) + .addSpendingLimit( + Card.AuthorizationControls.SpendingLimit.builder() + .interval( + Card.AuthorizationControls.SpendingLimit.Interval.ALL_TIME + ) + .addMerchantCategoryCode( + Card.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("code") + .build() + ) + .settlementAmount(0L) + .build() + ) + .build() + ) .billingAddress( Card.BillingAddress.builder() .city("New York") @@ -92,6 +239,81 @@ internal class CardListPageResponseTest { Card.builder() .id("card_oubs0hwk5rn6knuecxg2") .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + Card.AuthorizationControls.builder() + .maximumAuthorizationCount( + Card.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + Card.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + Card.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("identifier") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("identifier") + .build() + ) + .build() + ) + .merchantCategoryCode( + Card.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("code") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("code") + .build() + ) + .build() + ) + .merchantCountry( + Card.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("country") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("country") + .build() + ) + .build() + ) + .addSpendingLimit( + Card.AuthorizationControls.SpendingLimit.builder() + .interval( + Card.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .addMerchantCategoryCode( + Card.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("code") + .build() + ) + .settlementAmount(0L) + .build() + ) + .build() + ) .billingAddress( Card.BillingAddress.builder() .city("New York") diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardTest.kt index 21484135c..1dbecd2f5 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardTest.kt @@ -16,6 +16,75 @@ internal class CardTest { Card.builder() .id("card_oubs0hwk5rn6knuecxg2") .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + Card.AuthorizationControls.builder() + .maximumAuthorizationCount( + Card.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + Card.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + Card.AuthorizationControls.MerchantAcceptorIdentifier.Allowed + .builder() + .identifier("identifier") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantAcceptorIdentifier.Blocked + .builder() + .identifier("identifier") + .build() + ) + .build() + ) + .merchantCategoryCode( + Card.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("code") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("code") + .build() + ) + .build() + ) + .merchantCountry( + Card.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCountry.Allowed.builder() + .country("country") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCountry.Blocked.builder() + .country("country") + .build() + ) + .build() + ) + .addSpendingLimit( + Card.AuthorizationControls.SpendingLimit.builder() + .interval( + Card.AuthorizationControls.SpendingLimit.Interval.ALL_TIME + ) + .addMerchantCategoryCode( + Card.AuthorizationControls.SpendingLimit.MerchantCategoryCode + .builder() + .code("code") + .build() + ) + .settlementAmount(0L) + .build() + ) + .build() + ) .billingAddress( Card.BillingAddress.builder() .city("New York") @@ -45,6 +114,72 @@ internal class CardTest { assertThat(card.id()).isEqualTo("card_oubs0hwk5rn6knuecxg2") assertThat(card.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(card.authorizationControls()) + .contains( + Card.AuthorizationControls.builder() + .maximumAuthorizationCount( + Card.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + Card.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + Card.AuthorizationControls.MerchantAcceptorIdentifier.Allowed + .builder() + .identifier("identifier") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantAcceptorIdentifier.Blocked + .builder() + .identifier("identifier") + .build() + ) + .build() + ) + .merchantCategoryCode( + Card.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCategoryCode.Allowed.builder() + .code("code") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCategoryCode.Blocked.builder() + .code("code") + .build() + ) + .build() + ) + .merchantCountry( + Card.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCountry.Allowed.builder() + .country("country") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCountry.Blocked.builder() + .country("country") + .build() + ) + .build() + ) + .addSpendingLimit( + Card.AuthorizationControls.SpendingLimit.builder() + .interval(Card.AuthorizationControls.SpendingLimit.Interval.ALL_TIME) + .addMerchantCategoryCode( + Card.AuthorizationControls.SpendingLimit.MerchantCategoryCode + .builder() + .code("code") + .build() + ) + .settlementAmount(0L) + .build() + ) + .build() + ) assertThat(card.billingAddress()) .isEqualTo( Card.BillingAddress.builder() @@ -81,6 +216,75 @@ internal class CardTest { Card.builder() .id("card_oubs0hwk5rn6knuecxg2") .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + Card.AuthorizationControls.builder() + .maximumAuthorizationCount( + Card.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + Card.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + Card.AuthorizationControls.MerchantAcceptorIdentifier.Allowed + .builder() + .identifier("identifier") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantAcceptorIdentifier.Blocked + .builder() + .identifier("identifier") + .build() + ) + .build() + ) + .merchantCategoryCode( + Card.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("code") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("code") + .build() + ) + .build() + ) + .merchantCountry( + Card.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + Card.AuthorizationControls.MerchantCountry.Allowed.builder() + .country("country") + .build() + ) + .addBlocked( + Card.AuthorizationControls.MerchantCountry.Blocked.builder() + .country("country") + .build() + ) + .build() + ) + .addSpendingLimit( + Card.AuthorizationControls.SpendingLimit.builder() + .interval( + Card.AuthorizationControls.SpendingLimit.Interval.ALL_TIME + ) + .addMerchantCategoryCode( + Card.AuthorizationControls.SpendingLimit.MerchantCategoryCode + .builder() + .code("code") + .build() + ) + .settlementAmount(0L) + .build() + ) + .build() + ) .billingAddress( Card.BillingAddress.builder() .city("New York") diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardUpdateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardUpdateParamsTest.kt index 37d1feb05..6f856c9d3 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardUpdateParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cards/CardUpdateParamsTest.kt @@ -11,6 +11,81 @@ internal class CardUpdateParamsTest { fun create() { CardUpdateParams.builder() .cardId("card_oubs0hwk5rn6knuecxg2") + .authorizationControls( + CardUpdateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardUpdateParams.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardUpdateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardUpdateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardUpdateParams.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardUpdateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardUpdateParams.BillingAddress.builder() .city("x") @@ -47,6 +122,87 @@ internal class CardUpdateParamsTest { val params = CardUpdateParams.builder() .cardId("card_oubs0hwk5rn6knuecxg2") + .authorizationControls( + CardUpdateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardUpdateParams.AuthorizationControls.MaximumAuthorizationCount + .builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .builder() + .addAllowed( + CardUpdateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardUpdateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardUpdateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardUpdateParams.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardUpdateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardUpdateParams.BillingAddress.builder() .city("x") @@ -70,6 +226,82 @@ internal class CardUpdateParamsTest { val body = params._body() + assertThat(body.authorizationControls()) + .contains( + CardUpdateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardUpdateParams.AuthorizationControls.MaximumAuthorizationCount.builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode.Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardUpdateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCountry.Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCountry.Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardUpdateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardUpdateParams.AuthorizationControls.SpendingLimit.Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardUpdateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) assertThat(body.billingAddress()) .contains( CardUpdateParams.BillingAddress.builder() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardServiceAsyncTest.kt index e781b600b..9609a8e4d 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardServiceAsyncTest.kt @@ -27,6 +27,91 @@ internal class CardServiceAsyncTest { cardServiceAsync.create( CardCreateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + CardCreateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardCreateParams.AuthorizationControls.MaximumAuthorizationCount + .builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .builder() + .addAllowed( + CardCreateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardCreateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCountry + .Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCountry + .Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardCreateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardCreateParams.AuthorizationControls.SpendingLimit + .Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardCreateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardCreateParams.BillingAddress.builder() .city("x") @@ -80,6 +165,91 @@ internal class CardServiceAsyncTest { cardServiceAsync.update( CardUpdateParams.builder() .cardId("card_oubs0hwk5rn6knuecxg2") + .authorizationControls( + CardUpdateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardUpdateParams.AuthorizationControls.MaximumAuthorizationCount + .builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .builder() + .addAllowed( + CardUpdateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardUpdateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCountry + .Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCountry + .Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardUpdateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardUpdateParams.AuthorizationControls.SpendingLimit + .Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardUpdateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardUpdateParams.BillingAddress.builder() .city("x") diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardServiceTest.kt index ecab06e8f..c01f08966 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardServiceTest.kt @@ -27,6 +27,91 @@ internal class CardServiceTest { cardService.create( CardCreateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .authorizationControls( + CardCreateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardCreateParams.AuthorizationControls.MaximumAuthorizationCount + .builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier + .builder() + .addAllowed( + CardCreateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCategoryCode + .Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardCreateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardCreateParams.AuthorizationControls.MerchantCountry + .Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardCreateParams.AuthorizationControls.MerchantCountry + .Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardCreateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardCreateParams.AuthorizationControls.SpendingLimit + .Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardCreateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardCreateParams.BillingAddress.builder() .city("x") @@ -78,6 +163,91 @@ internal class CardServiceTest { cardService.update( CardUpdateParams.builder() .cardId("card_oubs0hwk5rn6knuecxg2") + .authorizationControls( + CardUpdateParams.AuthorizationControls.builder() + .maximumAuthorizationCount( + CardUpdateParams.AuthorizationControls.MaximumAuthorizationCount + .builder() + .allTime(0L) + .build() + ) + .merchantAcceptorIdentifier( + CardUpdateParams.AuthorizationControls.MerchantAcceptorIdentifier + .builder() + .addAllowed( + CardUpdateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Allowed + .builder() + .identifier("x") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls + .MerchantAcceptorIdentifier + .Blocked + .builder() + .identifier("x") + .build() + ) + .build() + ) + .merchantCategoryCode( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .Allowed + .builder() + .code("xxxx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCategoryCode + .Blocked + .builder() + .code("xxxx") + .build() + ) + .build() + ) + .merchantCountry( + CardUpdateParams.AuthorizationControls.MerchantCountry.builder() + .addAllowed( + CardUpdateParams.AuthorizationControls.MerchantCountry + .Allowed + .builder() + .country("xx") + .build() + ) + .addBlocked( + CardUpdateParams.AuthorizationControls.MerchantCountry + .Blocked + .builder() + .country("xx") + .build() + ) + .build() + ) + .addSpendingLimit( + CardUpdateParams.AuthorizationControls.SpendingLimit.builder() + .interval( + CardUpdateParams.AuthorizationControls.SpendingLimit + .Interval + .ALL_TIME + ) + .settlementAmount(0L) + .addMerchantCategoryCode( + CardUpdateParams.AuthorizationControls.SpendingLimit + .MerchantCategoryCode + .builder() + .code("x") + .build() + ) + .build() + ) + .build() + ) .billingAddress( CardUpdateParams.BillingAddress.builder() .city("x")