diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b8478cb7b..633bf86d7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.281.0" + ".": "0.282.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index c3a436da3..28ec9075a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 202 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-06c4af41ee358cc77681ee9eb3e3997fb985c94baa60639f3b21bba1a73dd990.yml -openapi_spec_hash: 636b35479a21d9be089b2d9b95646ba9 -config_hash: a185e9a72778cc4658ea73fb3a7f1354 +configured_endpoints: 214 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-a7861b46606a5a2d849c4403583805c1074983cffaf7acfe0a4d7bafa38c5efd.yml +openapi_spec_hash: a1cad356ebe1b02a67dbafbde7d7f1d4 +config_hash: b0b366d8c705ea0efe62093bae953e5a diff --git a/CHANGELOG.md b/CHANGELOG.md index e701702a4..b9e0bca0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.282.0 (2025-08-14) + +Full Changelog: [v0.281.0...v0.282.0](https://github.com/Increase/increase-java/compare/v0.281.0...v0.282.0) + +### Features + +* **api:** api update ([66b4681](https://github.com/Increase/increase-java/commit/66b46812c11f6043b88cde6e464fa24f228e0fdc)) + ## 0.281.0 (2025-08-14) Full Changelog: [v0.280.0...v0.281.0](https://github.com/Increase/increase-java/compare/v0.280.0...v0.281.0) diff --git a/README.md b/README.md index 4fac724ce..619f4da9b 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.281.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.281.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.281.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.282.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.282.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.282.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.281.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.282.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.281.0") +implementation("com.increase.api:increase-java:0.282.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.281.0") com.increase.api increase-java - 0.281.0 + 0.282.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index d291b7aa9..49e16c84d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.281.0" // x-release-please-version + version = "0.282.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt index 4d2321d88..c7b07e157 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt @@ -15,7 +15,10 @@ import com.increase.api.services.blocking.BookkeepingEntrySetService import com.increase.api.services.blocking.CardDisputeService import com.increase.api.services.blocking.CardPaymentService import com.increase.api.services.blocking.CardPurchaseSupplementService +import com.increase.api.services.blocking.CardPushTransferService import com.increase.api.services.blocking.CardService +import com.increase.api.services.blocking.CardTokenService +import com.increase.api.services.blocking.CardValidationService import com.increase.api.services.blocking.CheckDepositService import com.increase.api.services.blocking.CheckTransferService import com.increase.api.services.blocking.DeclinedTransactionService @@ -198,6 +201,12 @@ interface IncreaseClient { fun intrafiExclusions(): IntrafiExclusionService + fun cardTokens(): CardTokenService + + fun cardPushTransfers(): CardPushTransferService + + fun cardValidations(): CardValidationService + fun simulations(): SimulationService /** @@ -326,6 +335,12 @@ interface IncreaseClient { fun intrafiExclusions(): IntrafiExclusionService.WithRawResponse + fun cardTokens(): CardTokenService.WithRawResponse + + fun cardPushTransfers(): CardPushTransferService.WithRawResponse + + fun cardValidations(): CardValidationService.WithRawResponse + fun simulations(): SimulationService.WithRawResponse } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt index 927a30481..8c7a92a9e 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt @@ -15,7 +15,10 @@ import com.increase.api.services.async.BookkeepingEntrySetServiceAsync import com.increase.api.services.async.CardDisputeServiceAsync import com.increase.api.services.async.CardPaymentServiceAsync import com.increase.api.services.async.CardPurchaseSupplementServiceAsync +import com.increase.api.services.async.CardPushTransferServiceAsync import com.increase.api.services.async.CardServiceAsync +import com.increase.api.services.async.CardTokenServiceAsync +import com.increase.api.services.async.CardValidationServiceAsync import com.increase.api.services.async.CheckDepositServiceAsync import com.increase.api.services.async.CheckTransferServiceAsync import com.increase.api.services.async.DeclinedTransactionServiceAsync @@ -198,6 +201,12 @@ interface IncreaseClientAsync { fun intrafiExclusions(): IntrafiExclusionServiceAsync + fun cardTokens(): CardTokenServiceAsync + + fun cardPushTransfers(): CardPushTransferServiceAsync + + fun cardValidations(): CardValidationServiceAsync + fun simulations(): SimulationServiceAsync /** @@ -330,6 +339,12 @@ interface IncreaseClientAsync { fun intrafiExclusions(): IntrafiExclusionServiceAsync.WithRawResponse + fun cardTokens(): CardTokenServiceAsync.WithRawResponse + + fun cardPushTransfers(): CardPushTransferServiceAsync.WithRawResponse + + fun cardValidations(): CardValidationServiceAsync.WithRawResponse + fun simulations(): SimulationServiceAsync.WithRawResponse } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt index 4c417161a..1b70f5b20 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt @@ -28,8 +28,14 @@ import com.increase.api.services.async.CardPaymentServiceAsync import com.increase.api.services.async.CardPaymentServiceAsyncImpl import com.increase.api.services.async.CardPurchaseSupplementServiceAsync import com.increase.api.services.async.CardPurchaseSupplementServiceAsyncImpl +import com.increase.api.services.async.CardPushTransferServiceAsync +import com.increase.api.services.async.CardPushTransferServiceAsyncImpl import com.increase.api.services.async.CardServiceAsync import com.increase.api.services.async.CardServiceAsyncImpl +import com.increase.api.services.async.CardTokenServiceAsync +import com.increase.api.services.async.CardTokenServiceAsyncImpl +import com.increase.api.services.async.CardValidationServiceAsync +import com.increase.api.services.async.CardValidationServiceAsyncImpl import com.increase.api.services.async.CheckDepositServiceAsync import com.increase.api.services.async.CheckDepositServiceAsyncImpl import com.increase.api.services.async.CheckTransferServiceAsync @@ -332,6 +338,18 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa IntrafiExclusionServiceAsyncImpl(clientOptionsWithUserAgent) } + private val cardTokens: CardTokenServiceAsync by lazy { + CardTokenServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val cardPushTransfers: CardPushTransferServiceAsync by lazy { + CardPushTransferServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val cardValidations: CardValidationServiceAsync by lazy { + CardValidationServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val simulations: SimulationServiceAsync by lazy { SimulationServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -452,6 +470,12 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun webhooks(): WebhookServiceAsync = webhooks + override fun cardTokens(): CardTokenServiceAsync = cardTokens + + override fun cardPushTransfers(): CardPushTransferServiceAsync = cardPushTransfers + + override fun cardValidations(): CardValidationServiceAsync = cardValidations + override fun simulations(): SimulationServiceAsync = simulations override fun close() = clientOptions.httpClient.close() @@ -669,6 +693,18 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa IntrafiExclusionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardTokens: CardTokenServiceAsync.WithRawResponse by lazy { + CardTokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val cardPushTransfers: CardPushTransferServiceAsync.WithRawResponse by lazy { + CardPushTransferServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val cardValidations: CardValidationServiceAsync.WithRawResponse by lazy { + CardValidationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val simulations: SimulationServiceAsync.WithRawResponse by lazy { SimulationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -811,6 +847,13 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun intrafiExclusions(): IntrafiExclusionServiceAsync.WithRawResponse = intrafiExclusions + override fun cardTokens(): CardTokenServiceAsync.WithRawResponse = cardTokens + + override fun cardPushTransfers(): CardPushTransferServiceAsync.WithRawResponse = + cardPushTransfers + + override fun cardValidations(): CardValidationServiceAsync.WithRawResponse = cardValidations + override fun simulations(): SimulationServiceAsync.WithRawResponse = simulations } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt index f8e000c99..7546fa83d 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt @@ -28,8 +28,14 @@ import com.increase.api.services.blocking.CardPaymentService import com.increase.api.services.blocking.CardPaymentServiceImpl import com.increase.api.services.blocking.CardPurchaseSupplementService import com.increase.api.services.blocking.CardPurchaseSupplementServiceImpl +import com.increase.api.services.blocking.CardPushTransferService +import com.increase.api.services.blocking.CardPushTransferServiceImpl import com.increase.api.services.blocking.CardService import com.increase.api.services.blocking.CardServiceImpl +import com.increase.api.services.blocking.CardTokenService +import com.increase.api.services.blocking.CardTokenServiceImpl +import com.increase.api.services.blocking.CardValidationService +import com.increase.api.services.blocking.CardValidationServiceImpl import com.increase.api.services.blocking.CheckDepositService import com.increase.api.services.blocking.CheckDepositServiceImpl import com.increase.api.services.blocking.CheckTransferService @@ -317,6 +323,18 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } + private val cardTokens: CardTokenService by lazy { + CardTokenServiceImpl(clientOptionsWithUserAgent) + } + + private val cardPushTransfers: CardPushTransferService by lazy { + CardPushTransferServiceImpl(clientOptionsWithUserAgent) + } + + private val cardValidations: CardValidationService by lazy { + CardValidationServiceImpl(clientOptionsWithUserAgent) + } + private val simulations: SimulationService by lazy { SimulationServiceImpl(clientOptionsWithUserAgent) } @@ -436,6 +454,12 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun webhooks(): WebhookService = webhooks + override fun cardTokens(): CardTokenService = cardTokens + + override fun cardPushTransfers(): CardPushTransferService = cardPushTransfers + + override fun cardValidations(): CardValidationService = cardValidations + override fun simulations(): SimulationService = simulations override fun close() = clientOptions.httpClient.close() @@ -651,6 +675,18 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli IntrafiExclusionServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardTokens: CardTokenService.WithRawResponse by lazy { + CardTokenServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val cardPushTransfers: CardPushTransferService.WithRawResponse by lazy { + CardPushTransferServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val cardValidations: CardValidationService.WithRawResponse by lazy { + CardValidationServiceImpl.WithRawResponseImpl(clientOptions) + } + private val simulations: SimulationService.WithRawResponse by lazy { SimulationServiceImpl.WithRawResponseImpl(clientOptions) } @@ -789,6 +825,13 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun intrafiExclusions(): IntrafiExclusionService.WithRawResponse = intrafiExclusions + override fun cardTokens(): CardTokenService.WithRawResponse = cardTokens + + override fun cardPushTransfers(): CardPushTransferService.WithRawResponse = + cardPushTransfers + + override fun cardValidations(): CardValidationService.WithRawResponse = cardValidations + override fun simulations(): SimulationService.WithRawResponse = simulations } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransfer.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransfer.kt new file mode 100644 index 000000000..7de5285aa --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransfer.kt @@ -0,0 +1,5298 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +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.checkRequired +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Card Push Transfers send funds to a recipient's payment card in real-time. */ +class CardPushTransfer +private constructor( + private val id: JsonField, + private val acceptance: JsonField, + private val accountId: JsonField, + private val amount: JsonField, + private val approval: JsonField, + private val businessApplicationIdentifier: JsonField, + private val cancellation: JsonField, + private val createdAt: JsonField, + private val createdBy: JsonField, + private val currency: JsonField, + private val decline: JsonField, + private val idempotencyKey: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCityName: JsonField, + private val merchantName: JsonField, + private val merchantNamePrefix: JsonField, + private val merchantPostalCode: JsonField, + private val merchantState: JsonField, + private val recipientName: JsonField, + private val senderAddressCity: JsonField, + private val senderAddressLine1: JsonField, + private val senderAddressPostalCode: JsonField, + private val senderAddressState: JsonField, + private val senderName: JsonField, + private val sourceAccountNumberId: JsonField, + private val status: JsonField, + private val submission: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("acceptance") + @ExcludeMissing + acceptance: JsonField = JsonMissing.of(), + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("approval") @ExcludeMissing approval: JsonField = JsonMissing.of(), + @JsonProperty("business_application_identifier") + @ExcludeMissing + businessApplicationIdentifier: JsonField = JsonMissing.of(), + @JsonProperty("cancellation") + @ExcludeMissing + cancellation: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("decline") @ExcludeMissing decline: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_key") + @ExcludeMissing + idempotencyKey: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_city_name") + @ExcludeMissing + merchantCityName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name") + @ExcludeMissing + merchantName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name_prefix") + @ExcludeMissing + merchantNamePrefix: JsonField = JsonMissing.of(), + @JsonProperty("merchant_postal_code") + @ExcludeMissing + merchantPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_state") + @ExcludeMissing + merchantState: JsonField = JsonMissing.of(), + @JsonProperty("recipient_name") + @ExcludeMissing + recipientName: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_city") + @ExcludeMissing + senderAddressCity: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_line1") + @ExcludeMissing + senderAddressLine1: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_postal_code") + @ExcludeMissing + senderAddressPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_state") + @ExcludeMissing + senderAddressState: JsonField = JsonMissing.of(), + @JsonProperty("sender_name") + @ExcludeMissing + senderName: JsonField = JsonMissing.of(), + @JsonProperty("source_account_number_id") + @ExcludeMissing + sourceAccountNumberId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("submission") + @ExcludeMissing + submission: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + acceptance, + accountId, + amount, + approval, + businessApplicationIdentifier, + cancellation, + createdAt, + createdBy, + currency, + decline, + idempotencyKey, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantNamePrefix, + merchantPostalCode, + merchantState, + recipientName, + senderAddressCity, + senderAddressLine1, + senderAddressPostalCode, + senderAddressState, + senderName, + sourceAccountNumberId, + status, + submission, + type, + mutableMapOf(), + ) + + /** + * The Card Push Transfer's identifier. + * + * @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 id(): String = id.getRequired("id") + + /** + * If the transfer is accepted by the recipient bank, this will contain supplemental details. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun acceptance(): Optional = acceptance.getOptional("acceptance") + + /** + * The Account from which the transfer was sent. + * + * @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 accountId(): String = accountId.getRequired("account_id") + + /** + * The transfer amount in USD cents. + * + * @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 amount(): Long = amount.getRequired("amount") + + /** + * If your account requires approvals for transfers and the transfer was approved, this will + * contain details of the approval. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun approval(): Optional = approval.getOptional("approval") + + /** + * The Business Application Identifier describes the type of transaction being performed. Your + * program must be approved for the specified Business Application Identifier in order to use + * it. + * + * @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 businessApplicationIdentifier(): BusinessApplicationIdentifier = + businessApplicationIdentifier.getRequired("business_application_identifier") + + /** + * If your account requires approvals for transfers and the transfer was not approved, this will + * contain details of the cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cancellation(): Optional = cancellation.getOptional("cancellation") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the transfer + * was created. + * + * @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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * What object created the transfer, either via the API or the dashboard. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the transfer's currency. + * + * @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 currency(): Currency = currency.getRequired("currency") + + /** + * If the transfer is rejected by the card network or the destination financial institution, + * this will contain supplemental details. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun decline(): Optional = decline.getOptional("decline") + + /** + * The idempotency key you chose for this object. This value is unique across Increase and is + * used to ensure that a request is only processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun idempotencyKey(): Optional = idempotencyKey.getOptional("idempotency_key") + + /** + * The merchant category code (MCC) of the merchant (generally your business) sending the + * transfer. This is a four-digit code that describes the type of business or service provided + * by the merchant. Your program must be approved for the specified MCC in order to use it. + * + * @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 merchantCategoryCode(): String = merchantCategoryCode.getRequired("merchant_category_code") + + /** + * The city name of the merchant (generally your business) sending the transfer. + * + * @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 merchantCityName(): String = merchantCityName.getRequired("merchant_city_name") + + /** + * The merchant name shows up as the statement descriptor for the transfer. This is typically + * the name of your business or organization. + * + * @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 merchantName(): String = merchantName.getRequired("merchant_name") + + /** + * For certain Business Application Identifiers, the statement descriptor is + * `merchant_name_prefix*sender_name`, where the `merchant_name_prefix` is a one to four + * character prefix that identifies the merchant. + * + * @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 merchantNamePrefix(): String = merchantNamePrefix.getRequired("merchant_name_prefix") + + /** + * The postal code of the merchant (generally your business) sending the transfer. + * + * @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 merchantPostalCode(): String = merchantPostalCode.getRequired("merchant_postal_code") + + /** + * The state of the merchant (generally your business) sending the transfer. + * + * @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 merchantState(): String = merchantState.getRequired("merchant_state") + + /** + * The name of the funds recipient. + * + * @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 recipientName(): String = recipientName.getRequired("recipient_name") + + /** + * The city of the sender. + * + * @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 senderAddressCity(): String = senderAddressCity.getRequired("sender_address_city") + + /** + * The address line 1 of the sender. + * + * @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 senderAddressLine1(): String = senderAddressLine1.getRequired("sender_address_line1") + + /** + * The postal code of the sender. + * + * @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 senderAddressPostalCode(): String = + senderAddressPostalCode.getRequired("sender_address_postal_code") + + /** + * The state of the sender. + * + * @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 senderAddressState(): String = senderAddressState.getRequired("sender_address_state") + + /** + * The name of the funds originator. + * + * @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 senderName(): String = senderName.getRequired("sender_name") + + /** + * The Account Number the recipient will see as having sent the transfer. + * + * @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 sourceAccountNumberId(): String = + sourceAccountNumberId.getRequired("source_account_number_id") + + /** + * The lifecycle status of the transfer. + * + * @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 status(): Status = status.getRequired("status") + + /** + * After the transfer is submitted to the card network, this will contain supplemental details. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun submission(): Optional = submission.getOptional("submission") + + /** + * A constant representing the object's type. For this resource it will always be + * `card_push_transfer`. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [acceptance]. + * + * Unlike [acceptance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("acceptance") + @ExcludeMissing + fun _acceptance(): JsonField = acceptance + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [approval]. + * + * Unlike [approval], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("approval") @ExcludeMissing fun _approval(): JsonField = approval + + /** + * Returns the raw JSON value of [businessApplicationIdentifier]. + * + * Unlike [businessApplicationIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_application_identifier") + @ExcludeMissing + fun _businessApplicationIdentifier(): JsonField = + businessApplicationIdentifier + + /** + * Returns the raw JSON value of [cancellation]. + * + * Unlike [cancellation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cancellation") + @ExcludeMissing + fun _cancellation(): JsonField = cancellation + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [decline]. + * + * Unlike [decline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("decline") @ExcludeMissing fun _decline(): JsonField = decline + + /** + * Returns the raw JSON value of [idempotencyKey]. + * + * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("idempotency_key") + @ExcludeMissing + fun _idempotencyKey(): JsonField = idempotencyKey + + /** + * 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 [merchantCityName]. + * + * Unlike [merchantCityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_city_name") + @ExcludeMissing + fun _merchantCityName(): JsonField = merchantCityName + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant_name") + @ExcludeMissing + fun _merchantName(): JsonField = merchantName + + /** + * Returns the raw JSON value of [merchantNamePrefix]. + * + * Unlike [merchantNamePrefix], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_name_prefix") + @ExcludeMissing + fun _merchantNamePrefix(): JsonField = merchantNamePrefix + + /** + * Returns the raw JSON value of [merchantPostalCode]. + * + * Unlike [merchantPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_postal_code") + @ExcludeMissing + fun _merchantPostalCode(): JsonField = merchantPostalCode + + /** + * Returns the raw JSON value of [merchantState]. + * + * Unlike [merchantState], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant_state") + @ExcludeMissing + fun _merchantState(): JsonField = merchantState + + /** + * Returns the raw JSON value of [recipientName]. + * + * Unlike [recipientName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient_name") + @ExcludeMissing + fun _recipientName(): JsonField = recipientName + + /** + * Returns the raw JSON value of [senderAddressCity]. + * + * Unlike [senderAddressCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sender_address_city") + @ExcludeMissing + fun _senderAddressCity(): JsonField = senderAddressCity + + /** + * Returns the raw JSON value of [senderAddressLine1]. + * + * Unlike [senderAddressLine1], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sender_address_line1") + @ExcludeMissing + fun _senderAddressLine1(): JsonField = senderAddressLine1 + + /** + * Returns the raw JSON value of [senderAddressPostalCode]. + * + * Unlike [senderAddressPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sender_address_postal_code") + @ExcludeMissing + fun _senderAddressPostalCode(): JsonField = senderAddressPostalCode + + /** + * Returns the raw JSON value of [senderAddressState]. + * + * Unlike [senderAddressState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sender_address_state") + @ExcludeMissing + fun _senderAddressState(): JsonField = senderAddressState + + /** + * Returns the raw JSON value of [senderName]. + * + * Unlike [senderName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sender_name") @ExcludeMissing fun _senderName(): JsonField = senderName + + /** + * Returns the raw JSON value of [sourceAccountNumberId]. + * + * Unlike [sourceAccountNumberId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_account_number_id") + @ExcludeMissing + fun _sourceAccountNumberId(): JsonField = sourceAccountNumberId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [submission]. + * + * Unlike [submission], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("submission") + @ExcludeMissing + fun _submission(): JsonField = submission + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 [CardPushTransfer]. + * + * The following fields are required: + * ```java + * .id() + * .acceptance() + * .accountId() + * .amount() + * .approval() + * .businessApplicationIdentifier() + * .cancellation() + * .createdAt() + * .createdBy() + * .currency() + * .decline() + * .idempotencyKey() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantNamePrefix() + * .merchantPostalCode() + * .merchantState() + * .recipientName() + * .senderAddressCity() + * .senderAddressLine1() + * .senderAddressPostalCode() + * .senderAddressState() + * .senderName() + * .sourceAccountNumberId() + * .status() + * .submission() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransfer]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var acceptance: JsonField? = null + private var accountId: JsonField? = null + private var amount: JsonField? = null + private var approval: JsonField? = null + private var businessApplicationIdentifier: JsonField? = null + private var cancellation: JsonField? = null + private var createdAt: JsonField? = null + private var createdBy: JsonField? = null + private var currency: JsonField? = null + private var decline: JsonField? = null + private var idempotencyKey: JsonField? = null + private var merchantCategoryCode: JsonField? = null + private var merchantCityName: JsonField? = null + private var merchantName: JsonField? = null + private var merchantNamePrefix: JsonField? = null + private var merchantPostalCode: JsonField? = null + private var merchantState: JsonField? = null + private var recipientName: JsonField? = null + private var senderAddressCity: JsonField? = null + private var senderAddressLine1: JsonField? = null + private var senderAddressPostalCode: JsonField? = null + private var senderAddressState: JsonField? = null + private var senderName: JsonField? = null + private var sourceAccountNumberId: JsonField? = null + private var status: JsonField? = null + private var submission: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardPushTransfer: CardPushTransfer) = apply { + id = cardPushTransfer.id + acceptance = cardPushTransfer.acceptance + accountId = cardPushTransfer.accountId + amount = cardPushTransfer.amount + approval = cardPushTransfer.approval + businessApplicationIdentifier = cardPushTransfer.businessApplicationIdentifier + cancellation = cardPushTransfer.cancellation + createdAt = cardPushTransfer.createdAt + createdBy = cardPushTransfer.createdBy + currency = cardPushTransfer.currency + decline = cardPushTransfer.decline + idempotencyKey = cardPushTransfer.idempotencyKey + merchantCategoryCode = cardPushTransfer.merchantCategoryCode + merchantCityName = cardPushTransfer.merchantCityName + merchantName = cardPushTransfer.merchantName + merchantNamePrefix = cardPushTransfer.merchantNamePrefix + merchantPostalCode = cardPushTransfer.merchantPostalCode + merchantState = cardPushTransfer.merchantState + recipientName = cardPushTransfer.recipientName + senderAddressCity = cardPushTransfer.senderAddressCity + senderAddressLine1 = cardPushTransfer.senderAddressLine1 + senderAddressPostalCode = cardPushTransfer.senderAddressPostalCode + senderAddressState = cardPushTransfer.senderAddressState + senderName = cardPushTransfer.senderName + sourceAccountNumberId = cardPushTransfer.sourceAccountNumberId + status = cardPushTransfer.status + submission = cardPushTransfer.submission + type = cardPushTransfer.type + additionalProperties = cardPushTransfer.additionalProperties.toMutableMap() + } + + /** The Card Push Transfer's identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * If the transfer is accepted by the recipient bank, this will contain supplemental + * details. + */ + fun acceptance(acceptance: Acceptance?) = acceptance(JsonField.ofNullable(acceptance)) + + /** Alias for calling [Builder.acceptance] with `acceptance.orElse(null)`. */ + fun acceptance(acceptance: Optional) = acceptance(acceptance.getOrNull()) + + /** + * Sets [Builder.acceptance] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptance] with a well-typed [Acceptance] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptance(acceptance: JsonField) = apply { this.acceptance = acceptance } + + /** The Account from which the transfer was sent. */ + fun accountId(accountId: String) = accountId(JsonField.of(accountId)) + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountId(accountId: JsonField) = apply { this.accountId = accountId } + + /** The transfer amount in USD cents. */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * If your account requires approvals for transfers and the transfer was approved, this will + * contain details of the approval. + */ + fun approval(approval: Approval?) = approval(JsonField.ofNullable(approval)) + + /** Alias for calling [Builder.approval] with `approval.orElse(null)`. */ + fun approval(approval: Optional) = approval(approval.getOrNull()) + + /** + * Sets [Builder.approval] to an arbitrary JSON value. + * + * You should usually call [Builder.approval] with a well-typed [Approval] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun approval(approval: JsonField) = apply { this.approval = approval } + + /** + * The Business Application Identifier describes the type of transaction being performed. + * Your program must be approved for the specified Business Application Identifier in order + * to use it. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: BusinessApplicationIdentifier + ) = businessApplicationIdentifier(JsonField.of(businessApplicationIdentifier)) + + /** + * Sets [Builder.businessApplicationIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.businessApplicationIdentifier] with a well-typed + * [BusinessApplicationIdentifier] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: JsonField + ) = apply { this.businessApplicationIdentifier = businessApplicationIdentifier } + + /** + * If your account requires approvals for transfers and the transfer was not approved, this + * will contain details of the cancellation. + */ + fun cancellation(cancellation: Cancellation?) = + cancellation(JsonField.ofNullable(cancellation)) + + /** Alias for calling [Builder.cancellation] with `cancellation.orElse(null)`. */ + fun cancellation(cancellation: Optional) = + cancellation(cancellation.getOrNull()) + + /** + * Sets [Builder.cancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellation] with a well-typed [Cancellation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancellation(cancellation: JsonField) = apply { + this.cancellation = cancellation + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** What object created the transfer, either via the API or the dashboard. */ + fun createdBy(createdBy: CreatedBy?) = createdBy(JsonField.ofNullable(createdBy)) + + /** Alias for calling [Builder.createdBy] with `createdBy.orElse(null)`. */ + fun createdBy(createdBy: Optional) = createdBy(createdBy.getOrNull()) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [CreatedBy] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the transfer's currency. + */ + fun currency(currency: Currency) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [Currency] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * If the transfer is rejected by the card network or the destination financial institution, + * this will contain supplemental details. + */ + fun decline(decline: Decline?) = decline(JsonField.ofNullable(decline)) + + /** Alias for calling [Builder.decline] with `decline.orElse(null)`. */ + fun decline(decline: Optional) = decline(decline.getOrNull()) + + /** + * Sets [Builder.decline] to an arbitrary JSON value. + * + * You should usually call [Builder.decline] with a well-typed [Decline] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun decline(decline: JsonField) = apply { this.decline = decline } + + /** + * The idempotency key you chose for this object. This value is unique across Increase and + * is used to ensure that a request is only processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = + idempotencyKey(JsonField.ofNullable(idempotencyKey)) + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Sets [Builder.idempotencyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.idempotencyKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun idempotencyKey(idempotencyKey: JsonField) = apply { + this.idempotencyKey = idempotencyKey + } + + /** + * The merchant category code (MCC) of the merchant (generally your business) sending the + * transfer. This is a four-digit code that describes the type of business or service + * provided by the merchant. Your program must be approved for the specified MCC in order to + * use it. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] 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 + } + + /** The city name of the merchant (generally your business) sending the transfer. */ + fun merchantCityName(merchantCityName: String) = + merchantCityName(JsonField.of(merchantCityName)) + + /** + * Sets [Builder.merchantCityName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCityName(merchantCityName: JsonField) = apply { + this.merchantCityName = merchantCityName + } + + /** + * The merchant name shows up as the statement descriptor for the transfer. This is + * typically the name of your business or organization. + */ + fun merchantName(merchantName: String) = merchantName(JsonField.of(merchantName)) + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantName(merchantName: JsonField) = apply { + this.merchantName = merchantName + } + + /** + * For certain Business Application Identifiers, the statement descriptor is + * `merchant_name_prefix*sender_name`, where the `merchant_name_prefix` is a one to four + * character prefix that identifies the merchant. + */ + fun merchantNamePrefix(merchantNamePrefix: String) = + merchantNamePrefix(JsonField.of(merchantNamePrefix)) + + /** + * Sets [Builder.merchantNamePrefix] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantNamePrefix] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantNamePrefix(merchantNamePrefix: JsonField) = apply { + this.merchantNamePrefix = merchantNamePrefix + } + + /** The postal code of the merchant (generally your business) sending the transfer. */ + fun merchantPostalCode(merchantPostalCode: String) = + merchantPostalCode(JsonField.of(merchantPostalCode)) + + /** + * Sets [Builder.merchantPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantPostalCode(merchantPostalCode: JsonField) = apply { + this.merchantPostalCode = merchantPostalCode + } + + /** The state of the merchant (generally your business) sending the transfer. */ + fun merchantState(merchantState: String) = merchantState(JsonField.of(merchantState)) + + /** + * Sets [Builder.merchantState] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantState] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantState(merchantState: JsonField) = apply { + this.merchantState = merchantState + } + + /** The name of the funds recipient. */ + fun recipientName(recipientName: String) = recipientName(JsonField.of(recipientName)) + + /** + * Sets [Builder.recipientName] to an arbitrary JSON value. + * + * You should usually call [Builder.recipientName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipientName(recipientName: JsonField) = apply { + this.recipientName = recipientName + } + + /** The city of the sender. */ + fun senderAddressCity(senderAddressCity: String) = + senderAddressCity(JsonField.of(senderAddressCity)) + + /** + * Sets [Builder.senderAddressCity] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressCity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressCity(senderAddressCity: JsonField) = apply { + this.senderAddressCity = senderAddressCity + } + + /** The address line 1 of the sender. */ + fun senderAddressLine1(senderAddressLine1: String) = + senderAddressLine1(JsonField.of(senderAddressLine1)) + + /** + * Sets [Builder.senderAddressLine1] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressLine1] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressLine1(senderAddressLine1: JsonField) = apply { + this.senderAddressLine1 = senderAddressLine1 + } + + /** The postal code of the sender. */ + fun senderAddressPostalCode(senderAddressPostalCode: String) = + senderAddressPostalCode(JsonField.of(senderAddressPostalCode)) + + /** + * Sets [Builder.senderAddressPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressPostalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun senderAddressPostalCode(senderAddressPostalCode: JsonField) = apply { + this.senderAddressPostalCode = senderAddressPostalCode + } + + /** The state of the sender. */ + fun senderAddressState(senderAddressState: String) = + senderAddressState(JsonField.of(senderAddressState)) + + /** + * Sets [Builder.senderAddressState] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressState(senderAddressState: JsonField) = apply { + this.senderAddressState = senderAddressState + } + + /** The name of the funds originator. */ + fun senderName(senderName: String) = senderName(JsonField.of(senderName)) + + /** + * Sets [Builder.senderName] to an arbitrary JSON value. + * + * You should usually call [Builder.senderName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun senderName(senderName: JsonField) = apply { this.senderName = senderName } + + /** The Account Number the recipient will see as having sent the transfer. */ + fun sourceAccountNumberId(sourceAccountNumberId: String) = + sourceAccountNumberId(JsonField.of(sourceAccountNumberId)) + + /** + * Sets [Builder.sourceAccountNumberId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceAccountNumberId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceAccountNumberId(sourceAccountNumberId: JsonField) = apply { + this.sourceAccountNumberId = sourceAccountNumberId + } + + /** The lifecycle status of the transfer. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** + * After the transfer is submitted to the card network, this will contain supplemental + * details. + */ + fun submission(submission: Submission?) = submission(JsonField.ofNullable(submission)) + + /** Alias for calling [Builder.submission] with `submission.orElse(null)`. */ + fun submission(submission: Optional) = submission(submission.getOrNull()) + + /** + * Sets [Builder.submission] to an arbitrary JSON value. + * + * You should usually call [Builder.submission] with a well-typed [Submission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun submission(submission: JsonField) = apply { this.submission = submission } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_push_transfer`. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [CardPushTransfer]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .acceptance() + * .accountId() + * .amount() + * .approval() + * .businessApplicationIdentifier() + * .cancellation() + * .createdAt() + * .createdBy() + * .currency() + * .decline() + * .idempotencyKey() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantNamePrefix() + * .merchantPostalCode() + * .merchantState() + * .recipientName() + * .senderAddressCity() + * .senderAddressLine1() + * .senderAddressPostalCode() + * .senderAddressState() + * .senderName() + * .sourceAccountNumberId() + * .status() + * .submission() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardPushTransfer = + CardPushTransfer( + checkRequired("id", id), + checkRequired("acceptance", acceptance), + checkRequired("accountId", accountId), + checkRequired("amount", amount), + checkRequired("approval", approval), + checkRequired("businessApplicationIdentifier", businessApplicationIdentifier), + checkRequired("cancellation", cancellation), + checkRequired("createdAt", createdAt), + checkRequired("createdBy", createdBy), + checkRequired("currency", currency), + checkRequired("decline", decline), + checkRequired("idempotencyKey", idempotencyKey), + checkRequired("merchantCategoryCode", merchantCategoryCode), + checkRequired("merchantCityName", merchantCityName), + checkRequired("merchantName", merchantName), + checkRequired("merchantNamePrefix", merchantNamePrefix), + checkRequired("merchantPostalCode", merchantPostalCode), + checkRequired("merchantState", merchantState), + checkRequired("recipientName", recipientName), + checkRequired("senderAddressCity", senderAddressCity), + checkRequired("senderAddressLine1", senderAddressLine1), + checkRequired("senderAddressPostalCode", senderAddressPostalCode), + checkRequired("senderAddressState", senderAddressState), + checkRequired("senderName", senderName), + checkRequired("sourceAccountNumberId", sourceAccountNumberId), + checkRequired("status", status), + checkRequired("submission", submission), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardPushTransfer = apply { + if (validated) { + return@apply + } + + id() + acceptance().ifPresent { it.validate() } + accountId() + amount() + approval().ifPresent { it.validate() } + businessApplicationIdentifier().validate() + cancellation().ifPresent { it.validate() } + createdAt() + createdBy().ifPresent { it.validate() } + currency().validate() + decline().ifPresent { it.validate() } + idempotencyKey() + merchantCategoryCode() + merchantCityName() + merchantName() + merchantNamePrefix() + merchantPostalCode() + merchantState() + recipientName() + senderAddressCity() + senderAddressLine1() + senderAddressPostalCode() + senderAddressState() + senderName() + sourceAccountNumberId() + status().validate() + submission().ifPresent { it.validate() } + type().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 = + (if (id.asKnown().isPresent) 1 else 0) + + (acceptance.asKnown().getOrNull()?.validity() ?: 0) + + (if (accountId.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (approval.asKnown().getOrNull()?.validity() ?: 0) + + (businessApplicationIdentifier.asKnown().getOrNull()?.validity() ?: 0) + + (cancellation.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (createdBy.asKnown().getOrNull()?.validity() ?: 0) + + (currency.asKnown().getOrNull()?.validity() ?: 0) + + (decline.asKnown().getOrNull()?.validity() ?: 0) + + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + (if (merchantCategoryCode.asKnown().isPresent) 1 else 0) + + (if (merchantCityName.asKnown().isPresent) 1 else 0) + + (if (merchantName.asKnown().isPresent) 1 else 0) + + (if (merchantNamePrefix.asKnown().isPresent) 1 else 0) + + (if (merchantPostalCode.asKnown().isPresent) 1 else 0) + + (if (merchantState.asKnown().isPresent) 1 else 0) + + (if (recipientName.asKnown().isPresent) 1 else 0) + + (if (senderAddressCity.asKnown().isPresent) 1 else 0) + + (if (senderAddressLine1.asKnown().isPresent) 1 else 0) + + (if (senderAddressPostalCode.asKnown().isPresent) 1 else 0) + + (if (senderAddressState.asKnown().isPresent) 1 else 0) + + (if (senderName.asKnown().isPresent) 1 else 0) + + (if (sourceAccountNumberId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (submission.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** + * If the transfer is accepted by the recipient bank, this will contain supplemental details. + */ + class Acceptance + private constructor( + private val acceptedAt: JsonField, + private val authorizationIdentificationResponse: JsonField, + private val cardVerificationValue2Result: JsonField, + private val networkTransactionIdentifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_at") + @ExcludeMissing + acceptedAt: JsonField = JsonMissing.of(), + @JsonProperty("authorization_identification_response") + @ExcludeMissing + authorizationIdentificationResponse: JsonField = JsonMissing.of(), + @JsonProperty("card_verification_value2_result") + @ExcludeMissing + cardVerificationValue2Result: JsonField = + JsonMissing.of(), + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + networkTransactionIdentifier: JsonField = JsonMissing.of(), + ) : this( + acceptedAt, + authorizationIdentificationResponse, + cardVerificationValue2Result, + networkTransactionIdentifier, + mutableMapOf(), + ) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was accepted by the issuing bank. + * + * @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 acceptedAt(): OffsetDateTime = acceptedAt.getRequired("accepted_at") + + /** + * The authorization identification response from the issuing bank. + * + * @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 authorizationIdentificationResponse(): String = + authorizationIdentificationResponse.getRequired("authorization_identification_response") + + /** + * The result of the Card Verification Value 2 match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardVerificationValue2Result(): Optional = + cardVerificationValue2Result.getOptional("card_verification_value2_result") + + /** + * A unique identifier for the transaction on the card network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun networkTransactionIdentifier(): Optional = + networkTransactionIdentifier.getOptional("network_transaction_identifier") + + /** + * Returns the raw JSON value of [acceptedAt]. + * + * Unlike [acceptedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accepted_at") + @ExcludeMissing + fun _acceptedAt(): JsonField = acceptedAt + + /** + * Returns the raw JSON value of [authorizationIdentificationResponse]. + * + * Unlike [authorizationIdentificationResponse], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("authorization_identification_response") + @ExcludeMissing + fun _authorizationIdentificationResponse(): JsonField = + authorizationIdentificationResponse + + /** + * Returns the raw JSON value of [cardVerificationValue2Result]. + * + * Unlike [cardVerificationValue2Result], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("card_verification_value2_result") + @ExcludeMissing + fun _cardVerificationValue2Result(): JsonField = + cardVerificationValue2Result + + /** + * Returns the raw JSON value of [networkTransactionIdentifier]. + * + * Unlike [networkTransactionIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + fun _networkTransactionIdentifier(): JsonField = networkTransactionIdentifier + + @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 [Acceptance]. + * + * The following fields are required: + * ```java + * .acceptedAt() + * .authorizationIdentificationResponse() + * .cardVerificationValue2Result() + * .networkTransactionIdentifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Acceptance]. */ + class Builder internal constructor() { + + private var acceptedAt: JsonField? = null + private var authorizationIdentificationResponse: JsonField? = null + private var cardVerificationValue2Result: JsonField? = + null + private var networkTransactionIdentifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(acceptance: Acceptance) = apply { + acceptedAt = acceptance.acceptedAt + authorizationIdentificationResponse = acceptance.authorizationIdentificationResponse + cardVerificationValue2Result = acceptance.cardVerificationValue2Result + networkTransactionIdentifier = acceptance.networkTransactionIdentifier + additionalProperties = acceptance.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was accepted by the issuing bank. + */ + fun acceptedAt(acceptedAt: OffsetDateTime) = acceptedAt(JsonField.of(acceptedAt)) + + /** + * Sets [Builder.acceptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptedAt(acceptedAt: JsonField) = apply { + this.acceptedAt = acceptedAt + } + + /** The authorization identification response from the issuing bank. */ + fun authorizationIdentificationResponse(authorizationIdentificationResponse: String) = + authorizationIdentificationResponse( + JsonField.of(authorizationIdentificationResponse) + ) + + /** + * Sets [Builder.authorizationIdentificationResponse] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationIdentificationResponse] with a + * well-typed [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authorizationIdentificationResponse( + authorizationIdentificationResponse: JsonField + ) = apply { + this.authorizationIdentificationResponse = authorizationIdentificationResponse + } + + /** The result of the Card Verification Value 2 match. */ + fun cardVerificationValue2Result( + cardVerificationValue2Result: CardVerificationValue2Result? + ) = cardVerificationValue2Result(JsonField.ofNullable(cardVerificationValue2Result)) + + /** + * Alias for calling [Builder.cardVerificationValue2Result] with + * `cardVerificationValue2Result.orElse(null)`. + */ + fun cardVerificationValue2Result( + cardVerificationValue2Result: Optional + ) = cardVerificationValue2Result(cardVerificationValue2Result.getOrNull()) + + /** + * Sets [Builder.cardVerificationValue2Result] to an arbitrary JSON value. + * + * You should usually call [Builder.cardVerificationValue2Result] with a well-typed + * [CardVerificationValue2Result] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardVerificationValue2Result( + cardVerificationValue2Result: JsonField + ) = apply { this.cardVerificationValue2Result = cardVerificationValue2Result } + + /** A unique identifier for the transaction on the card network. */ + fun networkTransactionIdentifier(networkTransactionIdentifier: String?) = + networkTransactionIdentifier(JsonField.ofNullable(networkTransactionIdentifier)) + + /** + * Alias for calling [Builder.networkTransactionIdentifier] with + * `networkTransactionIdentifier.orElse(null)`. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: Optional) = + networkTransactionIdentifier(networkTransactionIdentifier.getOrNull()) + + /** + * Sets [Builder.networkTransactionIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.networkTransactionIdentifier] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: JsonField) = + apply { + this.networkTransactionIdentifier = networkTransactionIdentifier + } + + 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 [Acceptance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedAt() + * .authorizationIdentificationResponse() + * .cardVerificationValue2Result() + * .networkTransactionIdentifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Acceptance = + Acceptance( + checkRequired("acceptedAt", acceptedAt), + checkRequired( + "authorizationIdentificationResponse", + authorizationIdentificationResponse, + ), + checkRequired("cardVerificationValue2Result", cardVerificationValue2Result), + checkRequired("networkTransactionIdentifier", networkTransactionIdentifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Acceptance = apply { + if (validated) { + return@apply + } + + acceptedAt() + authorizationIdentificationResponse() + cardVerificationValue2Result().ifPresent { it.validate() } + networkTransactionIdentifier() + 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 (acceptedAt.asKnown().isPresent) 1 else 0) + + (if (authorizationIdentificationResponse.asKnown().isPresent) 1 else 0) + + (cardVerificationValue2Result.asKnown().getOrNull()?.validity() ?: 0) + + (if (networkTransactionIdentifier.asKnown().isPresent) 1 else 0) + + /** The result of the Card Verification Value 2 match. */ + class CardVerificationValue2Result + @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 Card Verification Value 2 (CVV2) matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The Card Verification Value 2 (CVV2) does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + @JvmStatic fun of(value: String) = CardVerificationValue2Result(JsonField.of(value)) + } + + /** An enum containing [CardVerificationValue2Result]'s known values. */ + enum class Known { + /** The Card Verification Value 2 (CVV2) matches the expected value. */ + MATCH, + /** The Card Verification Value 2 (CVV2) does not match the expected value. */ + NO_MATCH, + } + + /** + * An enum containing [CardVerificationValue2Result]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardVerificationValue2Result] 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 Card Verification Value 2 (CVV2) matches the expected value. */ + MATCH, + /** The Card Verification Value 2 (CVV2) does not match the expected value. */ + NO_MATCH, + /** + * An enum member indicating that [CardVerificationValue2Result] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardVerificationValue2Result: $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(): CardVerificationValue2Result = 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 CardVerificationValue2Result && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Acceptance && + acceptedAt == other.acceptedAt && + authorizationIdentificationResponse == other.authorizationIdentificationResponse && + cardVerificationValue2Result == other.cardVerificationValue2Result && + networkTransactionIdentifier == other.networkTransactionIdentifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptedAt, + authorizationIdentificationResponse, + cardVerificationValue2Result, + networkTransactionIdentifier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Acceptance{acceptedAt=$acceptedAt, authorizationIdentificationResponse=$authorizationIdentificationResponse, cardVerificationValue2Result=$cardVerificationValue2Result, networkTransactionIdentifier=$networkTransactionIdentifier, additionalProperties=$additionalProperties}" + } + + /** + * If your account requires approvals for transfers and the transfer was approved, this will + * contain details of the approval. + */ + class Approval + private constructor( + private val approvedAt: JsonField, + private val approvedBy: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("approved_at") + @ExcludeMissing + approvedAt: JsonField = JsonMissing.of(), + @JsonProperty("approved_by") + @ExcludeMissing + approvedBy: JsonField = JsonMissing.of(), + ) : this(approvedAt, approvedBy, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was approved. + * + * @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 approvedAt(): OffsetDateTime = approvedAt.getRequired("approved_at") + + /** + * If the Transfer was approved by a user in the dashboard, the email address of that user. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun approvedBy(): Optional = approvedBy.getOptional("approved_by") + + /** + * Returns the raw JSON value of [approvedAt]. + * + * Unlike [approvedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("approved_at") + @ExcludeMissing + fun _approvedAt(): JsonField = approvedAt + + /** + * Returns the raw JSON value of [approvedBy]. + * + * Unlike [approvedBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("approved_by") + @ExcludeMissing + fun _approvedBy(): JsonField = approvedBy + + @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 [Approval]. + * + * The following fields are required: + * ```java + * .approvedAt() + * .approvedBy() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Approval]. */ + class Builder internal constructor() { + + private var approvedAt: JsonField? = null + private var approvedBy: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(approval: Approval) = apply { + approvedAt = approval.approvedAt + approvedBy = approval.approvedBy + additionalProperties = approval.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was approved. + */ + fun approvedAt(approvedAt: OffsetDateTime) = approvedAt(JsonField.of(approvedAt)) + + /** + * Sets [Builder.approvedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.approvedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun approvedAt(approvedAt: JsonField) = apply { + this.approvedAt = approvedAt + } + + /** + * If the Transfer was approved by a user in the dashboard, the email address of that + * user. + */ + fun approvedBy(approvedBy: String?) = approvedBy(JsonField.ofNullable(approvedBy)) + + /** Alias for calling [Builder.approvedBy] with `approvedBy.orElse(null)`. */ + fun approvedBy(approvedBy: Optional) = approvedBy(approvedBy.getOrNull()) + + /** + * Sets [Builder.approvedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.approvedBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun approvedBy(approvedBy: JsonField) = apply { this.approvedBy = approvedBy } + + 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 [Approval]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .approvedAt() + * .approvedBy() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Approval = + Approval( + checkRequired("approvedAt", approvedAt), + checkRequired("approvedBy", approvedBy), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Approval = apply { + if (validated) { + return@apply + } + + approvedAt() + approvedBy() + 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 (approvedAt.asKnown().isPresent) 1 else 0) + + (if (approvedBy.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Approval && + approvedAt == other.approvedAt && + approvedBy == other.approvedBy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(approvedAt, approvedBy, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Approval{approvedAt=$approvedAt, approvedBy=$approvedBy, additionalProperties=$additionalProperties}" + } + + /** + * The Business Application Identifier describes the type of transaction being performed. Your + * program must be approved for the specified Business Application Identifier in order to use + * it. + */ + class BusinessApplicationIdentifier + @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 { + + /** Account to Account */ + @JvmField val ACCOUNT_TO_ACCOUNT = of("account_to_account") + + /** Business to Business */ + @JvmField val BUSINESS_TO_BUSINESS = of("business_to_business") + + /** Money Transfer Bank Initiated */ + @JvmField val MONEY_TRANSFER_BANK_INITIATED = of("money_transfer_bank_initiated") + + /** Non-Card Bill Payment */ + @JvmField val NON_CARD_BILL_PAYMENT = of("non_card_bill_payment") + + /** Consumer Bill Payment */ + @JvmField val CONSUMER_BILL_PAYMENT = of("consumer_bill_payment") + + /** Card Bill Payment */ + @JvmField val CARD_BILL_PAYMENT = of("card_bill_payment") + + /** Funds Disbursement */ + @JvmField val FUNDS_DISBURSEMENT = of("funds_disbursement") + + /** Funds Transfer */ + @JvmField val FUNDS_TRANSFER = of("funds_transfer") + + /** Loyalty and Offers */ + @JvmField val LOYALTY_AND_OFFERS = of("loyalty_and_offers") + + /** Merchant Disbursement */ + @JvmField val MERCHANT_DISBURSEMENT = of("merchant_disbursement") + + /** Merchant Payment */ + @JvmField val MERCHANT_PAYMENT = of("merchant_payment") + + /** Person to Person */ + @JvmField val PERSON_TO_PERSON = of("person_to_person") + + /** Top Up */ + @JvmField val TOP_UP = of("top_up") + + /** Wallet Transfer */ + @JvmField val WALLET_TRANSFER = of("wallet_transfer") + + @JvmStatic fun of(value: String) = BusinessApplicationIdentifier(JsonField.of(value)) + } + + /** An enum containing [BusinessApplicationIdentifier]'s known values. */ + enum class Known { + /** Account to Account */ + ACCOUNT_TO_ACCOUNT, + /** Business to Business */ + BUSINESS_TO_BUSINESS, + /** Money Transfer Bank Initiated */ + MONEY_TRANSFER_BANK_INITIATED, + /** Non-Card Bill Payment */ + NON_CARD_BILL_PAYMENT, + /** Consumer Bill Payment */ + CONSUMER_BILL_PAYMENT, + /** Card Bill Payment */ + CARD_BILL_PAYMENT, + /** Funds Disbursement */ + FUNDS_DISBURSEMENT, + /** Funds Transfer */ + FUNDS_TRANSFER, + /** Loyalty and Offers */ + LOYALTY_AND_OFFERS, + /** Merchant Disbursement */ + MERCHANT_DISBURSEMENT, + /** Merchant Payment */ + MERCHANT_PAYMENT, + /** Person to Person */ + PERSON_TO_PERSON, + /** Top Up */ + TOP_UP, + /** Wallet Transfer */ + WALLET_TRANSFER, + } + + /** + * An enum containing [BusinessApplicationIdentifier]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BusinessApplicationIdentifier] 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 { + /** Account to Account */ + ACCOUNT_TO_ACCOUNT, + /** Business to Business */ + BUSINESS_TO_BUSINESS, + /** Money Transfer Bank Initiated */ + MONEY_TRANSFER_BANK_INITIATED, + /** Non-Card Bill Payment */ + NON_CARD_BILL_PAYMENT, + /** Consumer Bill Payment */ + CONSUMER_BILL_PAYMENT, + /** Card Bill Payment */ + CARD_BILL_PAYMENT, + /** Funds Disbursement */ + FUNDS_DISBURSEMENT, + /** Funds Transfer */ + FUNDS_TRANSFER, + /** Loyalty and Offers */ + LOYALTY_AND_OFFERS, + /** Merchant Disbursement */ + MERCHANT_DISBURSEMENT, + /** Merchant Payment */ + MERCHANT_PAYMENT, + /** Person to Person */ + PERSON_TO_PERSON, + /** Top Up */ + TOP_UP, + /** Wallet Transfer */ + WALLET_TRANSFER, + /** + * An enum member indicating that [BusinessApplicationIdentifier] 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) { + ACCOUNT_TO_ACCOUNT -> Value.ACCOUNT_TO_ACCOUNT + BUSINESS_TO_BUSINESS -> Value.BUSINESS_TO_BUSINESS + MONEY_TRANSFER_BANK_INITIATED -> Value.MONEY_TRANSFER_BANK_INITIATED + NON_CARD_BILL_PAYMENT -> Value.NON_CARD_BILL_PAYMENT + CONSUMER_BILL_PAYMENT -> Value.CONSUMER_BILL_PAYMENT + CARD_BILL_PAYMENT -> Value.CARD_BILL_PAYMENT + FUNDS_DISBURSEMENT -> Value.FUNDS_DISBURSEMENT + FUNDS_TRANSFER -> Value.FUNDS_TRANSFER + LOYALTY_AND_OFFERS -> Value.LOYALTY_AND_OFFERS + MERCHANT_DISBURSEMENT -> Value.MERCHANT_DISBURSEMENT + MERCHANT_PAYMENT -> Value.MERCHANT_PAYMENT + PERSON_TO_PERSON -> Value.PERSON_TO_PERSON + TOP_UP -> Value.TOP_UP + WALLET_TRANSFER -> Value.WALLET_TRANSFER + 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) { + ACCOUNT_TO_ACCOUNT -> Known.ACCOUNT_TO_ACCOUNT + BUSINESS_TO_BUSINESS -> Known.BUSINESS_TO_BUSINESS + MONEY_TRANSFER_BANK_INITIATED -> Known.MONEY_TRANSFER_BANK_INITIATED + NON_CARD_BILL_PAYMENT -> Known.NON_CARD_BILL_PAYMENT + CONSUMER_BILL_PAYMENT -> Known.CONSUMER_BILL_PAYMENT + CARD_BILL_PAYMENT -> Known.CARD_BILL_PAYMENT + FUNDS_DISBURSEMENT -> Known.FUNDS_DISBURSEMENT + FUNDS_TRANSFER -> Known.FUNDS_TRANSFER + LOYALTY_AND_OFFERS -> Known.LOYALTY_AND_OFFERS + MERCHANT_DISBURSEMENT -> Known.MERCHANT_DISBURSEMENT + MERCHANT_PAYMENT -> Known.MERCHANT_PAYMENT + PERSON_TO_PERSON -> Known.PERSON_TO_PERSON + TOP_UP -> Known.TOP_UP + WALLET_TRANSFER -> Known.WALLET_TRANSFER + else -> + throw IncreaseInvalidDataException( + "Unknown BusinessApplicationIdentifier: $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(): BusinessApplicationIdentifier = 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 BusinessApplicationIdentifier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * If your account requires approvals for transfers and the transfer was not approved, this will + * contain details of the cancellation. + */ + class Cancellation + private constructor( + private val canceledAt: JsonField, + private val canceledBy: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("canceled_by") + @ExcludeMissing + canceledBy: JsonField = JsonMissing.of(), + ) : this(canceledAt, canceledBy, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Transfer was canceled. + * + * @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 canceledAt(): OffsetDateTime = canceledAt.getRequired("canceled_at") + + /** + * If the Transfer was canceled by a user in the dashboard, the email address of that user. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun canceledBy(): Optional = canceledBy.getOptional("canceled_by") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [canceledBy]. + * + * Unlike [canceledBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("canceled_by") + @ExcludeMissing + fun _canceledBy(): JsonField = canceledBy + + @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 [Cancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledBy() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var canceledBy: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cancellation: Cancellation) = apply { + canceledAt = cancellation.canceledAt + canceledBy = cancellation.canceledBy + additionalProperties = cancellation.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Transfer was canceled. + */ + fun canceledAt(canceledAt: OffsetDateTime) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** + * If the Transfer was canceled by a user in the dashboard, the email address of that + * user. + */ + fun canceledBy(canceledBy: String?) = canceledBy(JsonField.ofNullable(canceledBy)) + + /** Alias for calling [Builder.canceledBy] with `canceledBy.orElse(null)`. */ + fun canceledBy(canceledBy: Optional) = canceledBy(canceledBy.getOrNull()) + + /** + * Sets [Builder.canceledBy] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledBy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canceledBy(canceledBy: JsonField) = apply { this.canceledBy = canceledBy } + + 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 [Cancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledBy() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Cancellation = + Cancellation( + checkRequired("canceledAt", canceledAt), + checkRequired("canceledBy", canceledBy), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Cancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + canceledBy() + 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 (canceledAt.asKnown().isPresent) 1 else 0) + + (if (canceledBy.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cancellation && + canceledAt == other.canceledAt && + canceledBy == other.canceledBy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, canceledBy, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cancellation{canceledAt=$canceledAt, canceledBy=$canceledBy, additionalProperties=$additionalProperties}" + } + + /** What object created the transfer, either via the API or the dashboard. */ + class CreatedBy + private constructor( + private val apiKey: JsonField, + private val category: JsonField, + private val oauthApplication: JsonField, + private val user: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("api_key") @ExcludeMissing apiKey: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("oauth_application") + @ExcludeMissing + oauthApplication: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonField = JsonMissing.of(), + ) : this(apiKey, category, oauthApplication, user, mutableMapOf()) + + /** + * If present, details about the API key that created the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("api_key") + + /** + * The type of object that created this transfer. + * + * @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 category(): Category = category.getRequired("category") + + /** + * If present, details about the OAuth Application that created the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun oauthApplication(): Optional = + oauthApplication.getOptional("oauth_application") + + /** + * If present, details about the User that created the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun user(): Optional = user.getOptional("user") + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [oauthApplication]. + * + * Unlike [oauthApplication], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("oauth_application") + @ExcludeMissing + fun _oauthApplication(): JsonField = oauthApplication + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonField = user + + @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 [CreatedBy]. + * + * The following fields are required: + * ```java + * .apiKey() + * .category() + * .oauthApplication() + * .user() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedBy]. */ + class Builder internal constructor() { + + private var apiKey: JsonField? = null + private var category: JsonField? = null + private var oauthApplication: JsonField? = null + private var user: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createdBy: CreatedBy) = apply { + apiKey = createdBy.apiKey + category = createdBy.category + oauthApplication = createdBy.oauthApplication + user = createdBy.user + additionalProperties = createdBy.additionalProperties.toMutableMap() + } + + /** If present, details about the API key that created the transfer. */ + fun apiKey(apiKey: ApiKey?) = apiKey(JsonField.ofNullable(apiKey)) + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [ApiKey] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + /** The type of object that created this transfer. */ + fun category(category: Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [Category] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun category(category: JsonField) = apply { this.category = category } + + /** If present, details about the OAuth Application that created the transfer. */ + fun oauthApplication(oauthApplication: OAuthApplication?) = + oauthApplication(JsonField.ofNullable(oauthApplication)) + + /** + * Alias for calling [Builder.oauthApplication] with `oauthApplication.orElse(null)`. + */ + fun oauthApplication(oauthApplication: Optional) = + oauthApplication(oauthApplication.getOrNull()) + + /** + * Sets [Builder.oauthApplication] to an arbitrary JSON value. + * + * You should usually call [Builder.oauthApplication] with a well-typed + * [OAuthApplication] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun oauthApplication(oauthApplication: JsonField) = apply { + this.oauthApplication = oauthApplication + } + + /** If present, details about the User that created the transfer. */ + fun user(user: User?) = user(JsonField.ofNullable(user)) + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [User] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun user(user: JsonField) = apply { this.user = user } + + 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 [CreatedBy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKey() + * .category() + * .oauthApplication() + * .user() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreatedBy = + CreatedBy( + checkRequired("apiKey", apiKey), + checkRequired("category", category), + checkRequired("oauthApplication", oauthApplication), + checkRequired("user", user), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreatedBy = apply { + if (validated) { + return@apply + } + + apiKey().ifPresent { it.validate() } + category().validate() + oauthApplication().ifPresent { it.validate() } + user().ifPresent { 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 = + (apiKey.asKnown().getOrNull()?.validity() ?: 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (oauthApplication.asKnown().getOrNull()?.validity() ?: 0) + + (user.asKnown().getOrNull()?.validity() ?: 0) + + /** If present, details about the API key that created the transfer. */ + class ApiKey + private constructor( + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of() + ) : this(description, mutableMapOf()) + + /** + * The description set for the API key when it was created. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @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 [ApiKey]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKey]. */ + class Builder internal constructor() { + + private var description: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKey: ApiKey) = apply { + description = apiKey.description + additionalProperties = apiKey.additionalProperties.toMutableMap() + } + + /** The description set for the API key when it was created. */ + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + 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 [ApiKey]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApiKey = + ApiKey( + checkRequired("description", description), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ApiKey = apply { + if (validated) { + return@apply + } + + description() + 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 (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKey && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(description, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiKey{description=$description, additionalProperties=$additionalProperties}" + } + + /** The type of object that created this transfer. */ + class Category @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 { + + /** An API key. Details will be under the `api_key` object. */ + @JvmField val API_KEY = of("api_key") + + /** + * An OAuth application you connected to Increase. Details will be under the + * `oauth_application` object. + */ + @JvmField val OAUTH_APPLICATION = of("oauth_application") + + /** A User in the Increase dashboard. Details will be under the `user` object. */ + @JvmField val USER = of("user") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** An API key. Details will be under the `api_key` object. */ + API_KEY, + /** + * An OAuth application you connected to Increase. Details will be under the + * `oauth_application` object. + */ + OAUTH_APPLICATION, + /** A User in the Increase dashboard. Details will be under the `user` object. */ + USER, + } + + /** + * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Category] 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 { + /** An API key. Details will be under the `api_key` object. */ + API_KEY, + /** + * An OAuth application you connected to Increase. Details will be under the + * `oauth_application` object. + */ + OAUTH_APPLICATION, + /** A User in the Increase dashboard. Details will be under the `user` object. */ + USER, + /** + * An enum member indicating that [Category] 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) { + API_KEY -> Value.API_KEY + OAUTH_APPLICATION -> Value.OAUTH_APPLICATION + USER -> Value.USER + 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) { + API_KEY -> Known.API_KEY + OAUTH_APPLICATION -> Known.OAUTH_APPLICATION + USER -> Known.USER + else -> throw IncreaseInvalidDataException("Unknown Category: $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(): Category = 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 Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** If present, details about the OAuth Application that created the transfer. */ + class OAuthApplication + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * The name of the OAuth Application. + * + * @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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OAuthApplication]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthApplication]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(oauthApplication: OAuthApplication) = apply { + name = oauthApplication.name + additionalProperties = oauthApplication.additionalProperties.toMutableMap() + } + + /** The name of the OAuth Application. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OAuthApplication]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OAuthApplication = + OAuthApplication( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OAuthApplication = apply { + if (validated) { + return@apply + } + + name() + 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 (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthApplication && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OAuthApplication{name=$name, additionalProperties=$additionalProperties}" + } + + /** If present, details about the User that created the transfer. */ + class User + private constructor( + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of() + ) : this(email, mutableMapOf()) + + /** + * The email address of the User. + * + * @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 email(): String = email.getRequired("email") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @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 [User]. + * + * The following fields are required: + * ```java + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [User]. */ + class Builder internal constructor() { + + private var email: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(user: User) = apply { + email = user.email + additionalProperties = user.additionalProperties.toMutableMap() + } + + /** The email address of the User. */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + 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 [User]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): User = + User(checkRequired("email", email), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): User = apply { + if (validated) { + return@apply + } + + email() + 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 (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is User && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(email, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "User{email=$email, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedBy && + apiKey == other.apiKey && + category == other.category && + oauthApplication == other.oauthApplication && + user == other.user && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(apiKey, category, oauthApplication, user, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedBy{apiKey=$apiKey, category=$category, oauthApplication=$oauthApplication, user=$user, additionalProperties=$additionalProperties}" + } + + /** The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the transfer's currency. */ + class Currency @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 { + + /** Canadian Dollar (CAD) */ + @JvmField val CAD = of("CAD") + + /** Swiss Franc (CHF) */ + @JvmField val CHF = of("CHF") + + /** Euro (EUR) */ + @JvmField val EUR = of("EUR") + + /** British Pound (GBP) */ + @JvmField val GBP = of("GBP") + + /** Japanese Yen (JPY) */ + @JvmField val JPY = of("JPY") + + /** US Dollar (USD) */ + @JvmField val USD = of("USD") + + @JvmStatic fun of(value: String) = Currency(JsonField.of(value)) + } + + /** An enum containing [Currency]'s known values. */ + enum class Known { + /** Canadian Dollar (CAD) */ + CAD, + /** Swiss Franc (CHF) */ + CHF, + /** Euro (EUR) */ + EUR, + /** British Pound (GBP) */ + GBP, + /** Japanese Yen (JPY) */ + JPY, + /** US Dollar (USD) */ + USD, + } + + /** + * An enum containing [Currency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Currency] 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 { + /** Canadian Dollar (CAD) */ + CAD, + /** Swiss Franc (CHF) */ + CHF, + /** Euro (EUR) */ + EUR, + /** British Pound (GBP) */ + GBP, + /** Japanese Yen (JPY) */ + JPY, + /** US Dollar (USD) */ + USD, + /** An enum member indicating that [Currency] 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) { + CAD -> Value.CAD + CHF -> Value.CHF + EUR -> Value.EUR + GBP -> Value.GBP + JPY -> Value.JPY + USD -> Value.USD + 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) { + CAD -> Known.CAD + CHF -> Known.CHF + EUR -> Known.EUR + GBP -> Known.GBP + JPY -> Known.JPY + USD -> Known.USD + else -> throw IncreaseInvalidDataException("Unknown Currency: $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(): Currency = 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 Currency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * If the transfer is rejected by the card network or the destination financial institution, + * this will contain supplemental details. + */ + class Decline + private constructor( + private val declinedAt: JsonField, + private val networkTransactionIdentifier: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("declined_at") + @ExcludeMissing + declinedAt: JsonField = JsonMissing.of(), + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + networkTransactionIdentifier: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + ) : this(declinedAt, networkTransactionIdentifier, reason, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer declined. + * + * @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 declinedAt(): OffsetDateTime = declinedAt.getRequired("declined_at") + + /** + * A unique identifier for the transaction on the card network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun networkTransactionIdentifier(): Optional = + networkTransactionIdentifier.getOptional("network_transaction_identifier") + + /** + * The reason why the transfer was declined. + * + * @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 reason(): Reason = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [declinedAt]. + * + * Unlike [declinedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("declined_at") + @ExcludeMissing + fun _declinedAt(): JsonField = declinedAt + + /** + * Returns the raw JSON value of [networkTransactionIdentifier]. + * + * Unlike [networkTransactionIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + fun _networkTransactionIdentifier(): JsonField = networkTransactionIdentifier + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @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 [Decline]. + * + * The following fields are required: + * ```java + * .declinedAt() + * .networkTransactionIdentifier() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Decline]. */ + class Builder internal constructor() { + + private var declinedAt: JsonField? = null + private var networkTransactionIdentifier: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(decline: Decline) = apply { + declinedAt = decline.declinedAt + networkTransactionIdentifier = decline.networkTransactionIdentifier + reason = decline.reason + additionalProperties = decline.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer declined. + */ + fun declinedAt(declinedAt: OffsetDateTime) = declinedAt(JsonField.of(declinedAt)) + + /** + * Sets [Builder.declinedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.declinedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun declinedAt(declinedAt: JsonField) = apply { + this.declinedAt = declinedAt + } + + /** A unique identifier for the transaction on the card network. */ + fun networkTransactionIdentifier(networkTransactionIdentifier: String?) = + networkTransactionIdentifier(JsonField.ofNullable(networkTransactionIdentifier)) + + /** + * Alias for calling [Builder.networkTransactionIdentifier] with + * `networkTransactionIdentifier.orElse(null)`. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: Optional) = + networkTransactionIdentifier(networkTransactionIdentifier.getOrNull()) + + /** + * Sets [Builder.networkTransactionIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.networkTransactionIdentifier] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: JsonField) = + apply { + this.networkTransactionIdentifier = networkTransactionIdentifier + } + + /** The reason why the transfer was declined. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Reason] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + 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 [Decline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .declinedAt() + * .networkTransactionIdentifier() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Decline = + Decline( + checkRequired("declinedAt", declinedAt), + checkRequired("networkTransactionIdentifier", networkTransactionIdentifier), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Decline = apply { + if (validated) { + return@apply + } + + declinedAt() + networkTransactionIdentifier() + reason().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 = + (if (declinedAt.asKnown().isPresent) 1 else 0) + + (if (networkTransactionIdentifier.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** The reason why the transfer was declined. */ + class Reason @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 card issuer has declined the transaction without providing a specific reason. + */ + @JvmField val DO_NOT_HONOR = of("do_not_honor") + + /** + * The number of transactions for the card has exceeded the limit set by the issuer. + */ + @JvmField val ACTIVITY_COUNT_LIMIT_EXCEEDED = of("activity_count_limit_exceeded") + + /** + * The card issuer requires the cardholder to contact them for further information + * regarding the transaction. + */ + @JvmField val REFER_TO_CARD_ISSUER = of("refer_to_card_issuer") + + /** + * The card issuer requires the cardholder to contact them due to a special + * condition related to the transaction. + */ + @JvmField + val REFER_TO_CARD_ISSUER_SPECIAL_CONDITION = + of("refer_to_card_issuer_special_condition") + + /** The merchant is not valid for this transaction. */ + @JvmField val INVALID_MERCHANT = of("invalid_merchant") + + /** The card should be retained by the terminal. */ + @JvmField val PICK_UP_CARD = of("pick_up_card") + + /** An error occurred during processing of the transaction. */ + @JvmField val ERROR = of("error") + + /** The card should be retained by the terminal due to a special condition. */ + @JvmField val PICK_UP_CARD_SPECIAL = of("pick_up_card_special") + + /** The transaction is invalid and cannot be processed. */ + @JvmField val INVALID_TRANSACTION = of("invalid_transaction") + + /** The amount of the transaction is invalid. */ + @JvmField val INVALID_AMOUNT = of("invalid_amount") + + /** The account number provided is invalid. */ + @JvmField val INVALID_ACCOUNT_NUMBER = of("invalid_account_number") + + /** The issuer of the card could not be found. */ + @JvmField val NO_SUCH_ISSUER = of("no_such_issuer") + + /** The transaction should be re-entered for processing. */ + @JvmField val RE_ENTER_TRANSACTION = of("re_enter_transaction") + + /** There is no credit account associated with the card. */ + @JvmField val NO_CREDIT_ACCOUNT = of("no_credit_account") + + /** + * The card should be retained by the terminal because it has been reported lost. + */ + @JvmField val PICK_UP_CARD_LOST = of("pick_up_card_lost") + + /** + * The card should be retained by the terminal because it has been reported stolen. + */ + @JvmField val PICK_UP_CARD_STOLEN = of("pick_up_card_stolen") + + /** The account associated with the card has been closed. */ + @JvmField val CLOSED_ACCOUNT = of("closed_account") + + /** There are insufficient funds in the account to complete the transaction. */ + @JvmField val INSUFFICIENT_FUNDS = of("insufficient_funds") + + /** There is no checking account associated with the card. */ + @JvmField val NO_CHECKING_ACCOUNT = of("no_checking_account") + + /** There is no savings account associated with the card. */ + @JvmField val NO_SAVINGS_ACCOUNT = of("no_savings_account") + + /** The card has expired and cannot be used for transactions. */ + @JvmField val EXPIRED_CARD = of("expired_card") + + /** The transaction is not permitted for this cardholder. */ + @JvmField + val TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER = + of("transaction_not_permitted_to_cardholder") + + /** The transaction is not allowed at this terminal. */ + @JvmField + val TRANSACTION_NOT_ALLOWED_AT_TERMINAL = of("transaction_not_allowed_at_terminal") + + /** The transaction has been flagged as suspected fraud and cannot be processed. */ + @JvmField val SUSPECTED_FRAUD = of("suspected_fraud") + + /** The amount of activity on the card has exceeded the limit set by the issuer. */ + @JvmField val ACTIVITY_AMOUNT_LIMIT_EXCEEDED = of("activity_amount_limit_exceeded") + + /** + * The card has restrictions that prevent it from being used for this transaction. + */ + @JvmField val RESTRICTED_CARD = of("restricted_card") + + /** + * A security violation has occurred, preventing the transaction from being + * processed. + */ + @JvmField val SECURITY_VIOLATION = of("security_violation") + + /** + * The transaction does not meet the anti-money laundering requirements set by the + * issuer. + */ + @JvmField + val TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT = + of("transaction_does_not_fulfill_anti_money_laundering_requirement") + + /** The first use of the card has been blocked by the issuer. */ + @JvmField val BLOCKED_FIRST_USE = of("blocked_first_use") + + /** The credit issuer is currently unavailable to process the transaction. */ + @JvmField val CREDIT_ISSUER_UNAVAILABLE = of("credit_issuer_unavailable") + + /** + * The card verification value (CVV) results were negative, indicating a potential + * issue with the card. + */ + @JvmField + val NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS = + of("negative_card_verification_value_results") + + /** The issuer of the card is currently unavailable to process the transaction. */ + @JvmField val ISSUER_UNAVAILABLE = of("issuer_unavailable") + + /** The financial institution associated with the card could not be found. */ + @JvmField + val FINANCIAL_INSTITUTION_CANNOT_BE_FOUND = + of("financial_institution_cannot_be_found") + + /** The transaction cannot be completed due to an unspecified reason. */ + @JvmField + val TRANSACTION_CANNOT_BE_COMPLETED = of("transaction_cannot_be_completed") + + /** + * The transaction is a duplicate of a previous transaction and cannot be processed + * again. + */ + @JvmField val DUPLICATE_TRANSACTION = of("duplicate_transaction") + + /** + * A system malfunction occurred, preventing the transaction from being processed. + */ + @JvmField val SYSTEM_MALFUNCTION = of("system_malfunction") + + /** Additional customer authentication is required to complete the transaction. */ + @JvmField + val ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED = + of("additional_customer_authentication_required") + + /** + * The surcharge amount applied to the transaction is not permitted by the issuer. + */ + @JvmField val SURCHARGE_AMOUNT_NOT_PERMITTED = of("surcharge_amount_not_permitted") + + /** The transaction was declined due to a failure in verifying the CVV2 code. */ + @JvmField val DECLINE_FOR_CVV2_FAILURE = of("decline_for_cvv2_failure") + + /** A stop payment order has been placed on this transaction. */ + @JvmField val STOP_PAYMENT_ORDER = of("stop_payment_order") + + /** An order has been placed to revoke authorization for this transaction. */ + @JvmField + val REVOCATION_OF_AUTHORIZATION_ORDER = of("revocation_of_authorization_order") + + /** An order has been placed to revoke all authorizations for this cardholder. */ + @JvmField + val REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER = + of("revocation_of_all_authorizations_order") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** + * The card issuer has declined the transaction without providing a specific reason. + */ + DO_NOT_HONOR, + /** + * The number of transactions for the card has exceeded the limit set by the issuer. + */ + ACTIVITY_COUNT_LIMIT_EXCEEDED, + /** + * The card issuer requires the cardholder to contact them for further information + * regarding the transaction. + */ + REFER_TO_CARD_ISSUER, + /** + * The card issuer requires the cardholder to contact them due to a special + * condition related to the transaction. + */ + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION, + /** The merchant is not valid for this transaction. */ + INVALID_MERCHANT, + /** The card should be retained by the terminal. */ + PICK_UP_CARD, + /** An error occurred during processing of the transaction. */ + ERROR, + /** The card should be retained by the terminal due to a special condition. */ + PICK_UP_CARD_SPECIAL, + /** The transaction is invalid and cannot be processed. */ + INVALID_TRANSACTION, + /** The amount of the transaction is invalid. */ + INVALID_AMOUNT, + /** The account number provided is invalid. */ + INVALID_ACCOUNT_NUMBER, + /** The issuer of the card could not be found. */ + NO_SUCH_ISSUER, + /** The transaction should be re-entered for processing. */ + RE_ENTER_TRANSACTION, + /** There is no credit account associated with the card. */ + NO_CREDIT_ACCOUNT, + /** + * The card should be retained by the terminal because it has been reported lost. + */ + PICK_UP_CARD_LOST, + /** + * The card should be retained by the terminal because it has been reported stolen. + */ + PICK_UP_CARD_STOLEN, + /** The account associated with the card has been closed. */ + CLOSED_ACCOUNT, + /** There are insufficient funds in the account to complete the transaction. */ + INSUFFICIENT_FUNDS, + /** There is no checking account associated with the card. */ + NO_CHECKING_ACCOUNT, + /** There is no savings account associated with the card. */ + NO_SAVINGS_ACCOUNT, + /** The card has expired and cannot be used for transactions. */ + EXPIRED_CARD, + /** The transaction is not permitted for this cardholder. */ + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER, + /** The transaction is not allowed at this terminal. */ + TRANSACTION_NOT_ALLOWED_AT_TERMINAL, + /** The transaction has been flagged as suspected fraud and cannot be processed. */ + SUSPECTED_FRAUD, + /** The amount of activity on the card has exceeded the limit set by the issuer. */ + ACTIVITY_AMOUNT_LIMIT_EXCEEDED, + /** + * The card has restrictions that prevent it from being used for this transaction. + */ + RESTRICTED_CARD, + /** + * A security violation has occurred, preventing the transaction from being + * processed. + */ + SECURITY_VIOLATION, + /** + * The transaction does not meet the anti-money laundering requirements set by the + * issuer. + */ + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT, + /** The first use of the card has been blocked by the issuer. */ + BLOCKED_FIRST_USE, + /** The credit issuer is currently unavailable to process the transaction. */ + CREDIT_ISSUER_UNAVAILABLE, + /** + * The card verification value (CVV) results were negative, indicating a potential + * issue with the card. + */ + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS, + /** The issuer of the card is currently unavailable to process the transaction. */ + ISSUER_UNAVAILABLE, + /** The financial institution associated with the card could not be found. */ + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND, + /** The transaction cannot be completed due to an unspecified reason. */ + TRANSACTION_CANNOT_BE_COMPLETED, + /** + * The transaction is a duplicate of a previous transaction and cannot be processed + * again. + */ + DUPLICATE_TRANSACTION, + /** + * A system malfunction occurred, preventing the transaction from being processed. + */ + SYSTEM_MALFUNCTION, + /** Additional customer authentication is required to complete the transaction. */ + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED, + /** + * The surcharge amount applied to the transaction is not permitted by the issuer. + */ + SURCHARGE_AMOUNT_NOT_PERMITTED, + /** The transaction was declined due to a failure in verifying the CVV2 code. */ + DECLINE_FOR_CVV2_FAILURE, + /** A stop payment order has been placed on this transaction. */ + STOP_PAYMENT_ORDER, + /** An order has been placed to revoke authorization for this transaction. */ + REVOCATION_OF_AUTHORIZATION_ORDER, + /** An order has been placed to revoke all authorizations for this cardholder. */ + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] 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 card issuer has declined the transaction without providing a specific reason. + */ + DO_NOT_HONOR, + /** + * The number of transactions for the card has exceeded the limit set by the issuer. + */ + ACTIVITY_COUNT_LIMIT_EXCEEDED, + /** + * The card issuer requires the cardholder to contact them for further information + * regarding the transaction. + */ + REFER_TO_CARD_ISSUER, + /** + * The card issuer requires the cardholder to contact them due to a special + * condition related to the transaction. + */ + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION, + /** The merchant is not valid for this transaction. */ + INVALID_MERCHANT, + /** The card should be retained by the terminal. */ + PICK_UP_CARD, + /** An error occurred during processing of the transaction. */ + ERROR, + /** The card should be retained by the terminal due to a special condition. */ + PICK_UP_CARD_SPECIAL, + /** The transaction is invalid and cannot be processed. */ + INVALID_TRANSACTION, + /** The amount of the transaction is invalid. */ + INVALID_AMOUNT, + /** The account number provided is invalid. */ + INVALID_ACCOUNT_NUMBER, + /** The issuer of the card could not be found. */ + NO_SUCH_ISSUER, + /** The transaction should be re-entered for processing. */ + RE_ENTER_TRANSACTION, + /** There is no credit account associated with the card. */ + NO_CREDIT_ACCOUNT, + /** + * The card should be retained by the terminal because it has been reported lost. + */ + PICK_UP_CARD_LOST, + /** + * The card should be retained by the terminal because it has been reported stolen. + */ + PICK_UP_CARD_STOLEN, + /** The account associated with the card has been closed. */ + CLOSED_ACCOUNT, + /** There are insufficient funds in the account to complete the transaction. */ + INSUFFICIENT_FUNDS, + /** There is no checking account associated with the card. */ + NO_CHECKING_ACCOUNT, + /** There is no savings account associated with the card. */ + NO_SAVINGS_ACCOUNT, + /** The card has expired and cannot be used for transactions. */ + EXPIRED_CARD, + /** The transaction is not permitted for this cardholder. */ + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER, + /** The transaction is not allowed at this terminal. */ + TRANSACTION_NOT_ALLOWED_AT_TERMINAL, + /** The transaction has been flagged as suspected fraud and cannot be processed. */ + SUSPECTED_FRAUD, + /** The amount of activity on the card has exceeded the limit set by the issuer. */ + ACTIVITY_AMOUNT_LIMIT_EXCEEDED, + /** + * The card has restrictions that prevent it from being used for this transaction. + */ + RESTRICTED_CARD, + /** + * A security violation has occurred, preventing the transaction from being + * processed. + */ + SECURITY_VIOLATION, + /** + * The transaction does not meet the anti-money laundering requirements set by the + * issuer. + */ + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT, + /** The first use of the card has been blocked by the issuer. */ + BLOCKED_FIRST_USE, + /** The credit issuer is currently unavailable to process the transaction. */ + CREDIT_ISSUER_UNAVAILABLE, + /** + * The card verification value (CVV) results were negative, indicating a potential + * issue with the card. + */ + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS, + /** The issuer of the card is currently unavailable to process the transaction. */ + ISSUER_UNAVAILABLE, + /** The financial institution associated with the card could not be found. */ + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND, + /** The transaction cannot be completed due to an unspecified reason. */ + TRANSACTION_CANNOT_BE_COMPLETED, + /** + * The transaction is a duplicate of a previous transaction and cannot be processed + * again. + */ + DUPLICATE_TRANSACTION, + /** + * A system malfunction occurred, preventing the transaction from being processed. + */ + SYSTEM_MALFUNCTION, + /** Additional customer authentication is required to complete the transaction. */ + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED, + /** + * The surcharge amount applied to the transaction is not permitted by the issuer. + */ + SURCHARGE_AMOUNT_NOT_PERMITTED, + /** The transaction was declined due to a failure in verifying the CVV2 code. */ + DECLINE_FOR_CVV2_FAILURE, + /** A stop payment order has been placed on this transaction. */ + STOP_PAYMENT_ORDER, + /** An order has been placed to revoke authorization for this transaction. */ + REVOCATION_OF_AUTHORIZATION_ORDER, + /** An order has been placed to revoke all authorizations for this cardholder. */ + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER, + /** + * An enum member indicating that [Reason] 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) { + DO_NOT_HONOR -> Value.DO_NOT_HONOR + ACTIVITY_COUNT_LIMIT_EXCEEDED -> Value.ACTIVITY_COUNT_LIMIT_EXCEEDED + REFER_TO_CARD_ISSUER -> Value.REFER_TO_CARD_ISSUER + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION -> + Value.REFER_TO_CARD_ISSUER_SPECIAL_CONDITION + INVALID_MERCHANT -> Value.INVALID_MERCHANT + PICK_UP_CARD -> Value.PICK_UP_CARD + ERROR -> Value.ERROR + PICK_UP_CARD_SPECIAL -> Value.PICK_UP_CARD_SPECIAL + INVALID_TRANSACTION -> Value.INVALID_TRANSACTION + INVALID_AMOUNT -> Value.INVALID_AMOUNT + INVALID_ACCOUNT_NUMBER -> Value.INVALID_ACCOUNT_NUMBER + NO_SUCH_ISSUER -> Value.NO_SUCH_ISSUER + RE_ENTER_TRANSACTION -> Value.RE_ENTER_TRANSACTION + NO_CREDIT_ACCOUNT -> Value.NO_CREDIT_ACCOUNT + PICK_UP_CARD_LOST -> Value.PICK_UP_CARD_LOST + PICK_UP_CARD_STOLEN -> Value.PICK_UP_CARD_STOLEN + CLOSED_ACCOUNT -> Value.CLOSED_ACCOUNT + INSUFFICIENT_FUNDS -> Value.INSUFFICIENT_FUNDS + NO_CHECKING_ACCOUNT -> Value.NO_CHECKING_ACCOUNT + NO_SAVINGS_ACCOUNT -> Value.NO_SAVINGS_ACCOUNT + EXPIRED_CARD -> Value.EXPIRED_CARD + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER -> + Value.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + TRANSACTION_NOT_ALLOWED_AT_TERMINAL -> Value.TRANSACTION_NOT_ALLOWED_AT_TERMINAL + SUSPECTED_FRAUD -> Value.SUSPECTED_FRAUD + ACTIVITY_AMOUNT_LIMIT_EXCEEDED -> Value.ACTIVITY_AMOUNT_LIMIT_EXCEEDED + RESTRICTED_CARD -> Value.RESTRICTED_CARD + SECURITY_VIOLATION -> Value.SECURITY_VIOLATION + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT -> + Value.TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT + BLOCKED_FIRST_USE -> Value.BLOCKED_FIRST_USE + CREDIT_ISSUER_UNAVAILABLE -> Value.CREDIT_ISSUER_UNAVAILABLE + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS -> + Value.NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS + ISSUER_UNAVAILABLE -> Value.ISSUER_UNAVAILABLE + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND -> + Value.FINANCIAL_INSTITUTION_CANNOT_BE_FOUND + TRANSACTION_CANNOT_BE_COMPLETED -> Value.TRANSACTION_CANNOT_BE_COMPLETED + DUPLICATE_TRANSACTION -> Value.DUPLICATE_TRANSACTION + SYSTEM_MALFUNCTION -> Value.SYSTEM_MALFUNCTION + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED -> + Value.ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED + SURCHARGE_AMOUNT_NOT_PERMITTED -> Value.SURCHARGE_AMOUNT_NOT_PERMITTED + DECLINE_FOR_CVV2_FAILURE -> Value.DECLINE_FOR_CVV2_FAILURE + STOP_PAYMENT_ORDER -> Value.STOP_PAYMENT_ORDER + REVOCATION_OF_AUTHORIZATION_ORDER -> Value.REVOCATION_OF_AUTHORIZATION_ORDER + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER -> + Value.REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER + 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) { + DO_NOT_HONOR -> Known.DO_NOT_HONOR + ACTIVITY_COUNT_LIMIT_EXCEEDED -> Known.ACTIVITY_COUNT_LIMIT_EXCEEDED + REFER_TO_CARD_ISSUER -> Known.REFER_TO_CARD_ISSUER + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION -> + Known.REFER_TO_CARD_ISSUER_SPECIAL_CONDITION + INVALID_MERCHANT -> Known.INVALID_MERCHANT + PICK_UP_CARD -> Known.PICK_UP_CARD + ERROR -> Known.ERROR + PICK_UP_CARD_SPECIAL -> Known.PICK_UP_CARD_SPECIAL + INVALID_TRANSACTION -> Known.INVALID_TRANSACTION + INVALID_AMOUNT -> Known.INVALID_AMOUNT + INVALID_ACCOUNT_NUMBER -> Known.INVALID_ACCOUNT_NUMBER + NO_SUCH_ISSUER -> Known.NO_SUCH_ISSUER + RE_ENTER_TRANSACTION -> Known.RE_ENTER_TRANSACTION + NO_CREDIT_ACCOUNT -> Known.NO_CREDIT_ACCOUNT + PICK_UP_CARD_LOST -> Known.PICK_UP_CARD_LOST + PICK_UP_CARD_STOLEN -> Known.PICK_UP_CARD_STOLEN + CLOSED_ACCOUNT -> Known.CLOSED_ACCOUNT + INSUFFICIENT_FUNDS -> Known.INSUFFICIENT_FUNDS + NO_CHECKING_ACCOUNT -> Known.NO_CHECKING_ACCOUNT + NO_SAVINGS_ACCOUNT -> Known.NO_SAVINGS_ACCOUNT + EXPIRED_CARD -> Known.EXPIRED_CARD + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER -> + Known.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + TRANSACTION_NOT_ALLOWED_AT_TERMINAL -> Known.TRANSACTION_NOT_ALLOWED_AT_TERMINAL + SUSPECTED_FRAUD -> Known.SUSPECTED_FRAUD + ACTIVITY_AMOUNT_LIMIT_EXCEEDED -> Known.ACTIVITY_AMOUNT_LIMIT_EXCEEDED + RESTRICTED_CARD -> Known.RESTRICTED_CARD + SECURITY_VIOLATION -> Known.SECURITY_VIOLATION + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT -> + Known.TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT + BLOCKED_FIRST_USE -> Known.BLOCKED_FIRST_USE + CREDIT_ISSUER_UNAVAILABLE -> Known.CREDIT_ISSUER_UNAVAILABLE + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS -> + Known.NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS + ISSUER_UNAVAILABLE -> Known.ISSUER_UNAVAILABLE + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND -> + Known.FINANCIAL_INSTITUTION_CANNOT_BE_FOUND + TRANSACTION_CANNOT_BE_COMPLETED -> Known.TRANSACTION_CANNOT_BE_COMPLETED + DUPLICATE_TRANSACTION -> Known.DUPLICATE_TRANSACTION + SYSTEM_MALFUNCTION -> Known.SYSTEM_MALFUNCTION + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED -> + Known.ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED + SURCHARGE_AMOUNT_NOT_PERMITTED -> Known.SURCHARGE_AMOUNT_NOT_PERMITTED + DECLINE_FOR_CVV2_FAILURE -> Known.DECLINE_FOR_CVV2_FAILURE + STOP_PAYMENT_ORDER -> Known.STOP_PAYMENT_ORDER + REVOCATION_OF_AUTHORIZATION_ORDER -> Known.REVOCATION_OF_AUTHORIZATION_ORDER + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER -> + Known.REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER + else -> throw IncreaseInvalidDataException("Unknown Reason: $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(): Reason = 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 Reason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Decline && + declinedAt == other.declinedAt && + networkTransactionIdentifier == other.networkTransactionIdentifier && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(declinedAt, networkTransactionIdentifier, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Decline{declinedAt=$declinedAt, networkTransactionIdentifier=$networkTransactionIdentifier, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** The lifecycle status of the transfer. */ + class Status @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 transfer is pending approval. */ + @JvmField val PENDING_APPROVAL = of("pending_approval") + + /** The transfer has been canceled. */ + @JvmField val CANCELED = of("canceled") + + /** The transfer is pending review by Increase. */ + @JvmField val PENDING_REVIEWING = of("pending_reviewing") + + /** The transfer requires attention from an Increase operator. */ + @JvmField val REQUIRES_ATTENTION = of("requires_attention") + + /** The transfer is queued to be submitted to the card network. */ + @JvmField val PENDING_SUBMISSION = of("pending_submission") + + /** The transfer has been submitted and is pending a response from the card network. */ + @JvmField val SUBMITTED = of("submitted") + + /** The transfer has been sent successfully and is complete. */ + @JvmField val COMPLETE = of("complete") + + /** The transfer was declined by the network or the recipient's bank. */ + @JvmField val DECLINED = of("declined") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + /** The transfer is pending approval. */ + PENDING_APPROVAL, + /** The transfer has been canceled. */ + CANCELED, + /** The transfer is pending review by Increase. */ + PENDING_REVIEWING, + /** The transfer requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The transfer is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** The transfer has been submitted and is pending a response from the card network. */ + SUBMITTED, + /** The transfer has been sent successfully and is complete. */ + COMPLETE, + /** The transfer was declined by the network or the recipient's bank. */ + DECLINED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 transfer is pending approval. */ + PENDING_APPROVAL, + /** The transfer has been canceled. */ + CANCELED, + /** The transfer is pending review by Increase. */ + PENDING_REVIEWING, + /** The transfer requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The transfer is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** The transfer has been submitted and is pending a response from the card network. */ + SUBMITTED, + /** The transfer has been sent successfully and is complete. */ + COMPLETE, + /** The transfer was declined by the network or the recipient's bank. */ + DECLINED, + /** An enum member indicating that [Status] 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) { + PENDING_APPROVAL -> Value.PENDING_APPROVAL + CANCELED -> Value.CANCELED + PENDING_REVIEWING -> Value.PENDING_REVIEWING + REQUIRES_ATTENTION -> Value.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Value.PENDING_SUBMISSION + SUBMITTED -> Value.SUBMITTED + COMPLETE -> Value.COMPLETE + DECLINED -> Value.DECLINED + 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) { + PENDING_APPROVAL -> Known.PENDING_APPROVAL + CANCELED -> Known.CANCELED + PENDING_REVIEWING -> Known.PENDING_REVIEWING + REQUIRES_ATTENTION -> Known.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Known.PENDING_SUBMISSION + SUBMITTED -> Known.SUBMITTED + COMPLETE -> Known.COMPLETE + DECLINED -> Known.DECLINED + else -> throw IncreaseInvalidDataException("Unknown Status: $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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * After the transfer is submitted to the card network, this will contain supplemental details. + */ + class Submission + private constructor( + private val retrievalReferenceNumber: JsonField, + private val senderReference: JsonField, + private val submittedAt: JsonField, + private val traceNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("retrieval_reference_number") + @ExcludeMissing + retrievalReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("sender_reference") + @ExcludeMissing + senderReference: JsonField = JsonMissing.of(), + @JsonProperty("submitted_at") + @ExcludeMissing + submittedAt: JsonField = JsonMissing.of(), + @JsonProperty("trace_number") + @ExcludeMissing + traceNumber: JsonField = JsonMissing.of(), + ) : this( + retrievalReferenceNumber, + senderReference, + submittedAt, + traceNumber, + mutableMapOf(), + ) + + /** + * A 12-digit retrieval reference number that identifies the transfer. Usually a combination + * of a timestamp and the trace number. + * + * @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 retrievalReferenceNumber(): String = + retrievalReferenceNumber.getRequired("retrieval_reference_number") + + /** + * A unique reference for the transfer. + * + * @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 senderReference(): String = senderReference.getRequired("sender_reference") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was submitted to card network. + * + * @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 submittedAt(): OffsetDateTime = submittedAt.getRequired("submitted_at") + + /** + * A 6-digit trace number that identifies the transfer within a small window of time. + * + * @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 traceNumber(): String = traceNumber.getRequired("trace_number") + + /** + * Returns the raw JSON value of [retrievalReferenceNumber]. + * + * Unlike [retrievalReferenceNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("retrieval_reference_number") + @ExcludeMissing + fun _retrievalReferenceNumber(): JsonField = retrievalReferenceNumber + + /** + * Returns the raw JSON value of [senderReference]. + * + * Unlike [senderReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sender_reference") + @ExcludeMissing + fun _senderReference(): JsonField = senderReference + + /** + * Returns the raw JSON value of [submittedAt]. + * + * Unlike [submittedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("submitted_at") + @ExcludeMissing + fun _submittedAt(): JsonField = submittedAt + + /** + * Returns the raw JSON value of [traceNumber]. + * + * Unlike [traceNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_number") + @ExcludeMissing + fun _traceNumber(): JsonField = traceNumber + + @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 [Submission]. + * + * The following fields are required: + * ```java + * .retrievalReferenceNumber() + * .senderReference() + * .submittedAt() + * .traceNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Submission]. */ + class Builder internal constructor() { + + private var retrievalReferenceNumber: JsonField? = null + private var senderReference: JsonField? = null + private var submittedAt: JsonField? = null + private var traceNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(submission: Submission) = apply { + retrievalReferenceNumber = submission.retrievalReferenceNumber + senderReference = submission.senderReference + submittedAt = submission.submittedAt + traceNumber = submission.traceNumber + additionalProperties = submission.additionalProperties.toMutableMap() + } + + /** + * A 12-digit retrieval reference number that identifies the transfer. Usually a + * combination of a timestamp and the trace number. + */ + fun retrievalReferenceNumber(retrievalReferenceNumber: String) = + retrievalReferenceNumber(JsonField.of(retrievalReferenceNumber)) + + /** + * Sets [Builder.retrievalReferenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.retrievalReferenceNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun retrievalReferenceNumber(retrievalReferenceNumber: JsonField) = apply { + this.retrievalReferenceNumber = retrievalReferenceNumber + } + + /** A unique reference for the transfer. */ + fun senderReference(senderReference: String) = + senderReference(JsonField.of(senderReference)) + + /** + * Sets [Builder.senderReference] to an arbitrary JSON value. + * + * You should usually call [Builder.senderReference] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderReference(senderReference: JsonField) = apply { + this.senderReference = senderReference + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * transfer was submitted to card network. + */ + fun submittedAt(submittedAt: OffsetDateTime) = submittedAt(JsonField.of(submittedAt)) + + /** + * Sets [Builder.submittedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.submittedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun submittedAt(submittedAt: JsonField) = apply { + this.submittedAt = submittedAt + } + + /** + * A 6-digit trace number that identifies the transfer within a small window of time. + */ + fun traceNumber(traceNumber: String) = traceNumber(JsonField.of(traceNumber)) + + /** + * Sets [Builder.traceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.traceNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceNumber(traceNumber: JsonField) = apply { + this.traceNumber = traceNumber + } + + 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 [Submission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .retrievalReferenceNumber() + * .senderReference() + * .submittedAt() + * .traceNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Submission = + Submission( + checkRequired("retrievalReferenceNumber", retrievalReferenceNumber), + checkRequired("senderReference", senderReference), + checkRequired("submittedAt", submittedAt), + checkRequired("traceNumber", traceNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Submission = apply { + if (validated) { + return@apply + } + + retrievalReferenceNumber() + senderReference() + submittedAt() + traceNumber() + 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 (retrievalReferenceNumber.asKnown().isPresent) 1 else 0) + + (if (senderReference.asKnown().isPresent) 1 else 0) + + (if (submittedAt.asKnown().isPresent) 1 else 0) + + (if (traceNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Submission && + retrievalReferenceNumber == other.retrievalReferenceNumber && + senderReference == other.senderReference && + submittedAt == other.submittedAt && + traceNumber == other.traceNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + retrievalReferenceNumber, + senderReference, + submittedAt, + traceNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Submission{retrievalReferenceNumber=$retrievalReferenceNumber, senderReference=$senderReference, submittedAt=$submittedAt, traceNumber=$traceNumber, additionalProperties=$additionalProperties}" + } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_push_transfer`. + */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD_PUSH_TRANSFER = of("card_push_transfer") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CARD_PUSH_TRANSFER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD_PUSH_TRANSFER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD_PUSH_TRANSFER -> Value.CARD_PUSH_TRANSFER + 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) { + CARD_PUSH_TRANSFER -> Known.CARD_PUSH_TRANSFER + else -> throw IncreaseInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransfer && + id == other.id && + acceptance == other.acceptance && + accountId == other.accountId && + amount == other.amount && + approval == other.approval && + businessApplicationIdentifier == other.businessApplicationIdentifier && + cancellation == other.cancellation && + createdAt == other.createdAt && + createdBy == other.createdBy && + currency == other.currency && + decline == other.decline && + idempotencyKey == other.idempotencyKey && + merchantCategoryCode == other.merchantCategoryCode && + merchantCityName == other.merchantCityName && + merchantName == other.merchantName && + merchantNamePrefix == other.merchantNamePrefix && + merchantPostalCode == other.merchantPostalCode && + merchantState == other.merchantState && + recipientName == other.recipientName && + senderAddressCity == other.senderAddressCity && + senderAddressLine1 == other.senderAddressLine1 && + senderAddressPostalCode == other.senderAddressPostalCode && + senderAddressState == other.senderAddressState && + senderName == other.senderName && + sourceAccountNumberId == other.sourceAccountNumberId && + status == other.status && + submission == other.submission && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + acceptance, + accountId, + amount, + approval, + businessApplicationIdentifier, + cancellation, + createdAt, + createdBy, + currency, + decline, + idempotencyKey, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantNamePrefix, + merchantPostalCode, + merchantState, + recipientName, + senderAddressCity, + senderAddressLine1, + senderAddressPostalCode, + senderAddressState, + senderName, + sourceAccountNumberId, + status, + submission, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardPushTransfer{id=$id, acceptance=$acceptance, accountId=$accountId, amount=$amount, approval=$approval, businessApplicationIdentifier=$businessApplicationIdentifier, cancellation=$cancellation, createdAt=$createdAt, createdBy=$createdBy, currency=$currency, decline=$decline, idempotencyKey=$idempotencyKey, merchantCategoryCode=$merchantCategoryCode, merchantCityName=$merchantCityName, merchantName=$merchantName, merchantNamePrefix=$merchantNamePrefix, merchantPostalCode=$merchantPostalCode, merchantState=$merchantState, recipientName=$recipientName, senderAddressCity=$senderAddressCity, senderAddressLine1=$senderAddressLine1, senderAddressPostalCode=$senderAddressPostalCode, senderAddressState=$senderAddressState, senderName=$senderName, sourceAccountNumberId=$sourceAccountNumberId, status=$status, submission=$submission, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferApproveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferApproveParams.kt new file mode 100644 index 000000000..383886b3e --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferApproveParams.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Approves a Card Push Transfer in a pending_approval state. */ +class CardPushTransferApproveParams +private constructor( + private val cardPushTransferId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** The identifier of the Card Push Transfer to approve. */ + fun cardPushTransferId(): Optional = Optional.ofNullable(cardPushTransferId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardPushTransferApproveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CardPushTransferApproveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferApproveParams]. */ + class Builder internal constructor() { + + private var cardPushTransferId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardPushTransferApproveParams: CardPushTransferApproveParams) = apply { + cardPushTransferId = cardPushTransferApproveParams.cardPushTransferId + additionalHeaders = cardPushTransferApproveParams.additionalHeaders.toBuilder() + additionalQueryParams = cardPushTransferApproveParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + cardPushTransferApproveParams.additionalBodyProperties.toMutableMap() + } + + /** The identifier of the Card Push Transfer to approve. */ + fun cardPushTransferId(cardPushTransferId: String?) = apply { + this.cardPushTransferId = cardPushTransferId + } + + /** + * Alias for calling [Builder.cardPushTransferId] with `cardPushTransferId.orElse(null)`. + */ + fun cardPushTransferId(cardPushTransferId: Optional) = + cardPushTransferId(cardPushTransferId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CardPushTransferApproveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardPushTransferApproveParams = + CardPushTransferApproveParams( + cardPushTransferId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardPushTransferId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferApproveParams && + cardPushTransferId == other.cardPushTransferId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + cardPushTransferId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "CardPushTransferApproveParams{cardPushTransferId=$cardPushTransferId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCancelParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCancelParams.kt new file mode 100644 index 000000000..a88802af4 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCancelParams.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Cancels a Card Push Transfer in a pending_approval state. */ +class CardPushTransferCancelParams +private constructor( + private val cardPushTransferId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** The identifier of the pending Card Push Transfer to cancel. */ + fun cardPushTransferId(): Optional = Optional.ofNullable(cardPushTransferId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardPushTransferCancelParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardPushTransferCancelParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferCancelParams]. */ + class Builder internal constructor() { + + private var cardPushTransferId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardPushTransferCancelParams: CardPushTransferCancelParams) = apply { + cardPushTransferId = cardPushTransferCancelParams.cardPushTransferId + additionalHeaders = cardPushTransferCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = cardPushTransferCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + cardPushTransferCancelParams.additionalBodyProperties.toMutableMap() + } + + /** The identifier of the pending Card Push Transfer to cancel. */ + fun cardPushTransferId(cardPushTransferId: String?) = apply { + this.cardPushTransferId = cardPushTransferId + } + + /** + * Alias for calling [Builder.cardPushTransferId] with `cardPushTransferId.orElse(null)`. + */ + fun cardPushTransferId(cardPushTransferId: Optional) = + cardPushTransferId(cardPushTransferId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CardPushTransferCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardPushTransferCancelParams = + CardPushTransferCancelParams( + cardPushTransferId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardPushTransferId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferCancelParams && + cardPushTransferId == other.cardPushTransferId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + cardPushTransferId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "CardPushTransferCancelParams{cardPushTransferId=$cardPushTransferId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCreateParams.kt new file mode 100644 index 000000000..71d3c4063 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCreateParams.kt @@ -0,0 +1,2019 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +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.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a Card Push Transfer */ +class CardPushTransferCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The transfer amount in USD cents. For Card Push transfers, must be positive. + * + * @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 amount(): Long = body.amount() + + /** + * The Business Application Identifier describes the type of transaction being performed. Your + * program must be approved for the specified Business Application Identifier in order to use + * it. + * + * @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 businessApplicationIdentifier(): BusinessApplicationIdentifier = + body.businessApplicationIdentifier() + + /** + * The Increase identifier for the Card Token that represents the card number you're pushing + * funds to. + * + * @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 cardTokenId(): String = body.cardTokenId() + + /** + * The merchant category code (MCC) of the merchant (generally your business) sending the + * transfer. This is a four-digit code that describes the type of business or service provided + * by the merchant. Your program must be approved for the specified MCC in order to use it. + * + * @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 merchantCategoryCode(): String = body.merchantCategoryCode() + + /** + * The city name of the merchant (generally your business) sending the transfer. + * + * @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 merchantCityName(): String = body.merchantCityName() + + /** + * The merchant name shows up as the statement descriptor for the transfer. This is typically + * the name of your business or organization. + * + * @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 merchantName(): String = body.merchantName() + + /** + * For certain Business Application Identifiers, the statement descriptor is + * `merchant_name_prefix*sender_name`, where the `merchant_name_prefix` is a one to four + * character prefix that identifies the merchant. + * + * @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 merchantNamePrefix(): String = body.merchantNamePrefix() + + /** + * The postal code of the merchant (generally your business) sending the transfer. + * + * @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 merchantPostalCode(): String = body.merchantPostalCode() + + /** + * The state of the merchant (generally your business) sending the transfer. + * + * @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 merchantState(): String = body.merchantState() + + /** + * The name of the funds recipient. + * + * @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 recipientName(): String = body.recipientName() + + /** + * The city of the sender. + * + * @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 senderAddressCity(): String = body.senderAddressCity() + + /** + * The address line 1 of the sender. + * + * @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 senderAddressLine1(): String = body.senderAddressLine1() + + /** + * The postal code of the sender. + * + * @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 senderAddressPostalCode(): String = body.senderAddressPostalCode() + + /** + * The state of the sender. + * + * @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 senderAddressState(): String = body.senderAddressState() + + /** + * The name of the funds originator. + * + * @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 senderName(): String = body.senderName() + + /** + * The identifier of the Account Number from which to send the transfer. + * + * @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 sourceAccountNumberId(): String = body.sourceAccountNumberId() + + /** + * Whether the transfer requires explicit approval via the dashboard or API. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun requireApproval(): Optional = body.requireApproval() + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _amount(): JsonField = body._amount() + + /** + * Returns the raw JSON value of [businessApplicationIdentifier]. + * + * Unlike [businessApplicationIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _businessApplicationIdentifier(): JsonField = + body._businessApplicationIdentifier() + + /** + * Returns the raw JSON value of [cardTokenId]. + * + * Unlike [cardTokenId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _cardTokenId(): JsonField = body._cardTokenId() + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantCategoryCode(): JsonField = body._merchantCategoryCode() + + /** + * Returns the raw JSON value of [merchantCityName]. + * + * Unlike [merchantCityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantCityName(): JsonField = body._merchantCityName() + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _merchantName(): JsonField = body._merchantName() + + /** + * Returns the raw JSON value of [merchantNamePrefix]. + * + * Unlike [merchantNamePrefix], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantNamePrefix(): JsonField = body._merchantNamePrefix() + + /** + * Returns the raw JSON value of [merchantPostalCode]. + * + * Unlike [merchantPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantPostalCode(): JsonField = body._merchantPostalCode() + + /** + * Returns the raw JSON value of [merchantState]. + * + * Unlike [merchantState], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _merchantState(): JsonField = body._merchantState() + + /** + * Returns the raw JSON value of [recipientName]. + * + * Unlike [recipientName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _recipientName(): JsonField = body._recipientName() + + /** + * Returns the raw JSON value of [senderAddressCity]. + * + * Unlike [senderAddressCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _senderAddressCity(): JsonField = body._senderAddressCity() + + /** + * Returns the raw JSON value of [senderAddressLine1]. + * + * Unlike [senderAddressLine1], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _senderAddressLine1(): JsonField = body._senderAddressLine1() + + /** + * Returns the raw JSON value of [senderAddressPostalCode]. + * + * Unlike [senderAddressPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _senderAddressPostalCode(): JsonField = body._senderAddressPostalCode() + + /** + * Returns the raw JSON value of [senderAddressState]. + * + * Unlike [senderAddressState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _senderAddressState(): JsonField = body._senderAddressState() + + /** + * Returns the raw JSON value of [senderName]. + * + * Unlike [senderName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _senderName(): JsonField = body._senderName() + + /** + * Returns the raw JSON value of [sourceAccountNumberId]. + * + * Unlike [sourceAccountNumberId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _sourceAccountNumberId(): JsonField = body._sourceAccountNumberId() + + /** + * Returns the raw JSON value of [requireApproval]. + * + * Unlike [requireApproval], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _requireApproval(): JsonField = body._requireApproval() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardPushTransferCreateParams]. + * + * The following fields are required: + * ```java + * .amount() + * .businessApplicationIdentifier() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantNamePrefix() + * .merchantPostalCode() + * .merchantState() + * .recipientName() + * .senderAddressCity() + * .senderAddressLine1() + * .senderAddressPostalCode() + * .senderAddressState() + * .senderName() + * .sourceAccountNumberId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardPushTransferCreateParams: CardPushTransferCreateParams) = apply { + body = cardPushTransferCreateParams.body.toBuilder() + additionalHeaders = cardPushTransferCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardPushTransferCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * 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: + * - [amount] + * - [businessApplicationIdentifier] + * - [cardTokenId] + * - [merchantCategoryCode] + * - [merchantCityName] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The transfer amount in USD cents. For Card Push transfers, must be positive. */ + fun amount(amount: Long) = apply { body.amount(amount) } + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + + /** + * The Business Application Identifier describes the type of transaction being performed. + * Your program must be approved for the specified Business Application Identifier in order + * to use it. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: BusinessApplicationIdentifier + ) = apply { body.businessApplicationIdentifier(businessApplicationIdentifier) } + + /** + * Sets [Builder.businessApplicationIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.businessApplicationIdentifier] with a well-typed + * [BusinessApplicationIdentifier] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: JsonField + ) = apply { body.businessApplicationIdentifier(businessApplicationIdentifier) } + + /** + * The Increase identifier for the Card Token that represents the card number you're pushing + * funds to. + */ + fun cardTokenId(cardTokenId: String) = apply { body.cardTokenId(cardTokenId) } + + /** + * Sets [Builder.cardTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardTokenId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardTokenId(cardTokenId: JsonField) = apply { body.cardTokenId(cardTokenId) } + + /** + * The merchant category code (MCC) of the merchant (generally your business) sending the + * transfer. This is a four-digit code that describes the type of business or service + * provided by the merchant. Your program must be approved for the specified MCC in order to + * use it. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = apply { + body.merchantCategoryCode(merchantCategoryCode) + } + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = apply { + body.merchantCategoryCode(merchantCategoryCode) + } + + /** The city name of the merchant (generally your business) sending the transfer. */ + fun merchantCityName(merchantCityName: String) = apply { + body.merchantCityName(merchantCityName) + } + + /** + * Sets [Builder.merchantCityName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCityName(merchantCityName: JsonField) = apply { + body.merchantCityName(merchantCityName) + } + + /** + * The merchant name shows up as the statement descriptor for the transfer. This is + * typically the name of your business or organization. + */ + fun merchantName(merchantName: String) = apply { body.merchantName(merchantName) } + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantName(merchantName: JsonField) = apply { + body.merchantName(merchantName) + } + + /** + * For certain Business Application Identifiers, the statement descriptor is + * `merchant_name_prefix*sender_name`, where the `merchant_name_prefix` is a one to four + * character prefix that identifies the merchant. + */ + fun merchantNamePrefix(merchantNamePrefix: String) = apply { + body.merchantNamePrefix(merchantNamePrefix) + } + + /** + * Sets [Builder.merchantNamePrefix] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantNamePrefix] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantNamePrefix(merchantNamePrefix: JsonField) = apply { + body.merchantNamePrefix(merchantNamePrefix) + } + + /** The postal code of the merchant (generally your business) sending the transfer. */ + fun merchantPostalCode(merchantPostalCode: String) = apply { + body.merchantPostalCode(merchantPostalCode) + } + + /** + * Sets [Builder.merchantPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantPostalCode(merchantPostalCode: JsonField) = apply { + body.merchantPostalCode(merchantPostalCode) + } + + /** The state of the merchant (generally your business) sending the transfer. */ + fun merchantState(merchantState: String) = apply { body.merchantState(merchantState) } + + /** + * Sets [Builder.merchantState] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantState] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantState(merchantState: JsonField) = apply { + body.merchantState(merchantState) + } + + /** The name of the funds recipient. */ + fun recipientName(recipientName: String) = apply { body.recipientName(recipientName) } + + /** + * Sets [Builder.recipientName] to an arbitrary JSON value. + * + * You should usually call [Builder.recipientName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipientName(recipientName: JsonField) = apply { + body.recipientName(recipientName) + } + + /** The city of the sender. */ + fun senderAddressCity(senderAddressCity: String) = apply { + body.senderAddressCity(senderAddressCity) + } + + /** + * Sets [Builder.senderAddressCity] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressCity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressCity(senderAddressCity: JsonField) = apply { + body.senderAddressCity(senderAddressCity) + } + + /** The address line 1 of the sender. */ + fun senderAddressLine1(senderAddressLine1: String) = apply { + body.senderAddressLine1(senderAddressLine1) + } + + /** + * Sets [Builder.senderAddressLine1] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressLine1] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressLine1(senderAddressLine1: JsonField) = apply { + body.senderAddressLine1(senderAddressLine1) + } + + /** The postal code of the sender. */ + fun senderAddressPostalCode(senderAddressPostalCode: String) = apply { + body.senderAddressPostalCode(senderAddressPostalCode) + } + + /** + * Sets [Builder.senderAddressPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressPostalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun senderAddressPostalCode(senderAddressPostalCode: JsonField) = apply { + body.senderAddressPostalCode(senderAddressPostalCode) + } + + /** The state of the sender. */ + fun senderAddressState(senderAddressState: String) = apply { + body.senderAddressState(senderAddressState) + } + + /** + * Sets [Builder.senderAddressState] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressState(senderAddressState: JsonField) = apply { + body.senderAddressState(senderAddressState) + } + + /** The name of the funds originator. */ + fun senderName(senderName: String) = apply { body.senderName(senderName) } + + /** + * Sets [Builder.senderName] to an arbitrary JSON value. + * + * You should usually call [Builder.senderName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun senderName(senderName: JsonField) = apply { body.senderName(senderName) } + + /** The identifier of the Account Number from which to send the transfer. */ + fun sourceAccountNumberId(sourceAccountNumberId: String) = apply { + body.sourceAccountNumberId(sourceAccountNumberId) + } + + /** + * Sets [Builder.sourceAccountNumberId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceAccountNumberId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceAccountNumberId(sourceAccountNumberId: JsonField) = apply { + body.sourceAccountNumberId(sourceAccountNumberId) + } + + /** Whether the transfer requires explicit approval via the dashboard or API. */ + fun requireApproval(requireApproval: Boolean) = apply { + body.requireApproval(requireApproval) + } + + /** + * Sets [Builder.requireApproval] to an arbitrary JSON value. + * + * You should usually call [Builder.requireApproval] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requireApproval(requireApproval: JsonField) = apply { + body.requireApproval(requireApproval) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardPushTransferCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .businessApplicationIdentifier() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantNamePrefix() + * .merchantPostalCode() + * .merchantState() + * .recipientName() + * .senderAddressCity() + * .senderAddressLine1() + * .senderAddressPostalCode() + * .senderAddressState() + * .senderName() + * .sourceAccountNumberId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardPushTransferCreateParams = + CardPushTransferCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val amount: JsonField, + private val businessApplicationIdentifier: JsonField, + private val cardTokenId: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCityName: JsonField, + private val merchantName: JsonField, + private val merchantNamePrefix: JsonField, + private val merchantPostalCode: JsonField, + private val merchantState: JsonField, + private val recipientName: JsonField, + private val senderAddressCity: JsonField, + private val senderAddressLine1: JsonField, + private val senderAddressPostalCode: JsonField, + private val senderAddressState: JsonField, + private val senderName: JsonField, + private val sourceAccountNumberId: JsonField, + private val requireApproval: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("business_application_identifier") + @ExcludeMissing + businessApplicationIdentifier: JsonField = + JsonMissing.of(), + @JsonProperty("card_token_id") + @ExcludeMissing + cardTokenId: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_city_name") + @ExcludeMissing + merchantCityName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name") + @ExcludeMissing + merchantName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name_prefix") + @ExcludeMissing + merchantNamePrefix: JsonField = JsonMissing.of(), + @JsonProperty("merchant_postal_code") + @ExcludeMissing + merchantPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_state") + @ExcludeMissing + merchantState: JsonField = JsonMissing.of(), + @JsonProperty("recipient_name") + @ExcludeMissing + recipientName: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_city") + @ExcludeMissing + senderAddressCity: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_line1") + @ExcludeMissing + senderAddressLine1: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_postal_code") + @ExcludeMissing + senderAddressPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("sender_address_state") + @ExcludeMissing + senderAddressState: JsonField = JsonMissing.of(), + @JsonProperty("sender_name") + @ExcludeMissing + senderName: JsonField = JsonMissing.of(), + @JsonProperty("source_account_number_id") + @ExcludeMissing + sourceAccountNumberId: JsonField = JsonMissing.of(), + @JsonProperty("require_approval") + @ExcludeMissing + requireApproval: JsonField = JsonMissing.of(), + ) : this( + amount, + businessApplicationIdentifier, + cardTokenId, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantNamePrefix, + merchantPostalCode, + merchantState, + recipientName, + senderAddressCity, + senderAddressLine1, + senderAddressPostalCode, + senderAddressState, + senderName, + sourceAccountNumberId, + requireApproval, + mutableMapOf(), + ) + + /** + * The transfer amount in USD cents. For Card Push transfers, must be positive. + * + * @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 amount(): Long = amount.getRequired("amount") + + /** + * The Business Application Identifier describes the type of transaction being performed. + * Your program must be approved for the specified Business Application Identifier in order + * to use it. + * + * @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 businessApplicationIdentifier(): BusinessApplicationIdentifier = + businessApplicationIdentifier.getRequired("business_application_identifier") + + /** + * The Increase identifier for the Card Token that represents the card number you're pushing + * funds to. + * + * @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 cardTokenId(): String = cardTokenId.getRequired("card_token_id") + + /** + * The merchant category code (MCC) of the merchant (generally your business) sending the + * transfer. This is a four-digit code that describes the type of business or service + * provided by the merchant. Your program must be approved for the specified MCC in order to + * use it. + * + * @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 merchantCategoryCode(): String = + merchantCategoryCode.getRequired("merchant_category_code") + + /** + * The city name of the merchant (generally your business) sending the transfer. + * + * @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 merchantCityName(): String = merchantCityName.getRequired("merchant_city_name") + + /** + * The merchant name shows up as the statement descriptor for the transfer. This is + * typically the name of your business or organization. + * + * @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 merchantName(): String = merchantName.getRequired("merchant_name") + + /** + * For certain Business Application Identifiers, the statement descriptor is + * `merchant_name_prefix*sender_name`, where the `merchant_name_prefix` is a one to four + * character prefix that identifies the merchant. + * + * @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 merchantNamePrefix(): String = merchantNamePrefix.getRequired("merchant_name_prefix") + + /** + * The postal code of the merchant (generally your business) sending the transfer. + * + * @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 merchantPostalCode(): String = merchantPostalCode.getRequired("merchant_postal_code") + + /** + * The state of the merchant (generally your business) sending the transfer. + * + * @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 merchantState(): String = merchantState.getRequired("merchant_state") + + /** + * The name of the funds recipient. + * + * @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 recipientName(): String = recipientName.getRequired("recipient_name") + + /** + * The city of the sender. + * + * @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 senderAddressCity(): String = senderAddressCity.getRequired("sender_address_city") + + /** + * The address line 1 of the sender. + * + * @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 senderAddressLine1(): String = senderAddressLine1.getRequired("sender_address_line1") + + /** + * The postal code of the sender. + * + * @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 senderAddressPostalCode(): String = + senderAddressPostalCode.getRequired("sender_address_postal_code") + + /** + * The state of the sender. + * + * @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 senderAddressState(): String = senderAddressState.getRequired("sender_address_state") + + /** + * The name of the funds originator. + * + * @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 senderName(): String = senderName.getRequired("sender_name") + + /** + * The identifier of the Account Number from which to send the transfer. + * + * @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 sourceAccountNumberId(): String = + sourceAccountNumberId.getRequired("source_account_number_id") + + /** + * Whether the transfer requires explicit approval via the dashboard or API. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requireApproval(): Optional = requireApproval.getOptional("require_approval") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [businessApplicationIdentifier]. + * + * Unlike [businessApplicationIdentifier], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("business_application_identifier") + @ExcludeMissing + fun _businessApplicationIdentifier(): JsonField = + businessApplicationIdentifier + + /** + * Returns the raw JSON value of [cardTokenId]. + * + * Unlike [cardTokenId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token_id") + @ExcludeMissing + fun _cardTokenId(): JsonField = cardTokenId + + /** + * 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 [merchantCityName]. + * + * Unlike [merchantCityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_city_name") + @ExcludeMissing + fun _merchantCityName(): JsonField = merchantCityName + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_name") + @ExcludeMissing + fun _merchantName(): JsonField = merchantName + + /** + * Returns the raw JSON value of [merchantNamePrefix]. + * + * Unlike [merchantNamePrefix], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_name_prefix") + @ExcludeMissing + fun _merchantNamePrefix(): JsonField = merchantNamePrefix + + /** + * Returns the raw JSON value of [merchantPostalCode]. + * + * Unlike [merchantPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_postal_code") + @ExcludeMissing + fun _merchantPostalCode(): JsonField = merchantPostalCode + + /** + * Returns the raw JSON value of [merchantState]. + * + * Unlike [merchantState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_state") + @ExcludeMissing + fun _merchantState(): JsonField = merchantState + + /** + * Returns the raw JSON value of [recipientName]. + * + * Unlike [recipientName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("recipient_name") + @ExcludeMissing + fun _recipientName(): JsonField = recipientName + + /** + * Returns the raw JSON value of [senderAddressCity]. + * + * Unlike [senderAddressCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sender_address_city") + @ExcludeMissing + fun _senderAddressCity(): JsonField = senderAddressCity + + /** + * Returns the raw JSON value of [senderAddressLine1]. + * + * Unlike [senderAddressLine1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sender_address_line1") + @ExcludeMissing + fun _senderAddressLine1(): JsonField = senderAddressLine1 + + /** + * Returns the raw JSON value of [senderAddressPostalCode]. + * + * Unlike [senderAddressPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sender_address_postal_code") + @ExcludeMissing + fun _senderAddressPostalCode(): JsonField = senderAddressPostalCode + + /** + * Returns the raw JSON value of [senderAddressState]. + * + * Unlike [senderAddressState], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sender_address_state") + @ExcludeMissing + fun _senderAddressState(): JsonField = senderAddressState + + /** + * Returns the raw JSON value of [senderName]. + * + * Unlike [senderName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sender_name") + @ExcludeMissing + fun _senderName(): JsonField = senderName + + /** + * Returns the raw JSON value of [sourceAccountNumberId]. + * + * Unlike [sourceAccountNumberId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_account_number_id") + @ExcludeMissing + fun _sourceAccountNumberId(): JsonField = sourceAccountNumberId + + /** + * Returns the raw JSON value of [requireApproval]. + * + * Unlike [requireApproval], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("require_approval") + @ExcludeMissing + fun _requireApproval(): JsonField = requireApproval + + @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 [Body]. + * + * The following fields are required: + * ```java + * .amount() + * .businessApplicationIdentifier() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantNamePrefix() + * .merchantPostalCode() + * .merchantState() + * .recipientName() + * .senderAddressCity() + * .senderAddressLine1() + * .senderAddressPostalCode() + * .senderAddressState() + * .senderName() + * .sourceAccountNumberId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var businessApplicationIdentifier: JsonField? = + null + private var cardTokenId: JsonField? = null + private var merchantCategoryCode: JsonField? = null + private var merchantCityName: JsonField? = null + private var merchantName: JsonField? = null + private var merchantNamePrefix: JsonField? = null + private var merchantPostalCode: JsonField? = null + private var merchantState: JsonField? = null + private var recipientName: JsonField? = null + private var senderAddressCity: JsonField? = null + private var senderAddressLine1: JsonField? = null + private var senderAddressPostalCode: JsonField? = null + private var senderAddressState: JsonField? = null + private var senderName: JsonField? = null + private var sourceAccountNumberId: JsonField? = null + private var requireApproval: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + amount = body.amount + businessApplicationIdentifier = body.businessApplicationIdentifier + cardTokenId = body.cardTokenId + merchantCategoryCode = body.merchantCategoryCode + merchantCityName = body.merchantCityName + merchantName = body.merchantName + merchantNamePrefix = body.merchantNamePrefix + merchantPostalCode = body.merchantPostalCode + merchantState = body.merchantState + recipientName = body.recipientName + senderAddressCity = body.senderAddressCity + senderAddressLine1 = body.senderAddressLine1 + senderAddressPostalCode = body.senderAddressPostalCode + senderAddressState = body.senderAddressState + senderName = body.senderName + sourceAccountNumberId = body.sourceAccountNumberId + requireApproval = body.requireApproval + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The transfer amount in USD cents. For Card Push transfers, must be positive. */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The Business Application Identifier describes the type of transaction being + * performed. Your program must be approved for the specified Business Application + * Identifier in order to use it. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: BusinessApplicationIdentifier + ) = businessApplicationIdentifier(JsonField.of(businessApplicationIdentifier)) + + /** + * Sets [Builder.businessApplicationIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.businessApplicationIdentifier] with a well-typed + * [BusinessApplicationIdentifier] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: JsonField + ) = apply { this.businessApplicationIdentifier = businessApplicationIdentifier } + + /** + * The Increase identifier for the Card Token that represents the card number you're + * pushing funds to. + */ + fun cardTokenId(cardTokenId: String) = cardTokenId(JsonField.of(cardTokenId)) + + /** + * Sets [Builder.cardTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardTokenId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardTokenId(cardTokenId: JsonField) = apply { + this.cardTokenId = cardTokenId + } + + /** + * The merchant category code (MCC) of the merchant (generally your business) sending + * the transfer. This is a four-digit code that describes the type of business or + * service provided by the merchant. Your program must be approved for the specified MCC + * in order to use it. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] + * 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 + } + + /** The city name of the merchant (generally your business) sending the transfer. */ + fun merchantCityName(merchantCityName: String) = + merchantCityName(JsonField.of(merchantCityName)) + + /** + * Sets [Builder.merchantCityName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCityName(merchantCityName: JsonField) = apply { + this.merchantCityName = merchantCityName + } + + /** + * The merchant name shows up as the statement descriptor for the transfer. This is + * typically the name of your business or organization. + */ + fun merchantName(merchantName: String) = merchantName(JsonField.of(merchantName)) + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantName(merchantName: JsonField) = apply { + this.merchantName = merchantName + } + + /** + * For certain Business Application Identifiers, the statement descriptor is + * `merchant_name_prefix*sender_name`, where the `merchant_name_prefix` is a one to four + * character prefix that identifies the merchant. + */ + fun merchantNamePrefix(merchantNamePrefix: String) = + merchantNamePrefix(JsonField.of(merchantNamePrefix)) + + /** + * Sets [Builder.merchantNamePrefix] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantNamePrefix] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantNamePrefix(merchantNamePrefix: JsonField) = apply { + this.merchantNamePrefix = merchantNamePrefix + } + + /** The postal code of the merchant (generally your business) sending the transfer. */ + fun merchantPostalCode(merchantPostalCode: String) = + merchantPostalCode(JsonField.of(merchantPostalCode)) + + /** + * Sets [Builder.merchantPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantPostalCode(merchantPostalCode: JsonField) = apply { + this.merchantPostalCode = merchantPostalCode + } + + /** The state of the merchant (generally your business) sending the transfer. */ + fun merchantState(merchantState: String) = merchantState(JsonField.of(merchantState)) + + /** + * Sets [Builder.merchantState] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantState(merchantState: JsonField) = apply { + this.merchantState = merchantState + } + + /** The name of the funds recipient. */ + fun recipientName(recipientName: String) = recipientName(JsonField.of(recipientName)) + + /** + * Sets [Builder.recipientName] to an arbitrary JSON value. + * + * You should usually call [Builder.recipientName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recipientName(recipientName: JsonField) = apply { + this.recipientName = recipientName + } + + /** The city of the sender. */ + fun senderAddressCity(senderAddressCity: String) = + senderAddressCity(JsonField.of(senderAddressCity)) + + /** + * Sets [Builder.senderAddressCity] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressCity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressCity(senderAddressCity: JsonField) = apply { + this.senderAddressCity = senderAddressCity + } + + /** The address line 1 of the sender. */ + fun senderAddressLine1(senderAddressLine1: String) = + senderAddressLine1(JsonField.of(senderAddressLine1)) + + /** + * Sets [Builder.senderAddressLine1] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressLine1] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressLine1(senderAddressLine1: JsonField) = apply { + this.senderAddressLine1 = senderAddressLine1 + } + + /** The postal code of the sender. */ + fun senderAddressPostalCode(senderAddressPostalCode: String) = + senderAddressPostalCode(JsonField.of(senderAddressPostalCode)) + + /** + * Sets [Builder.senderAddressPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressPostalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun senderAddressPostalCode(senderAddressPostalCode: JsonField) = apply { + this.senderAddressPostalCode = senderAddressPostalCode + } + + /** The state of the sender. */ + fun senderAddressState(senderAddressState: String) = + senderAddressState(JsonField.of(senderAddressState)) + + /** + * Sets [Builder.senderAddressState] to an arbitrary JSON value. + * + * You should usually call [Builder.senderAddressState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderAddressState(senderAddressState: JsonField) = apply { + this.senderAddressState = senderAddressState + } + + /** The name of the funds originator. */ + fun senderName(senderName: String) = senderName(JsonField.of(senderName)) + + /** + * Sets [Builder.senderName] to an arbitrary JSON value. + * + * You should usually call [Builder.senderName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun senderName(senderName: JsonField) = apply { this.senderName = senderName } + + /** The identifier of the Account Number from which to send the transfer. */ + fun sourceAccountNumberId(sourceAccountNumberId: String) = + sourceAccountNumberId(JsonField.of(sourceAccountNumberId)) + + /** + * Sets [Builder.sourceAccountNumberId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceAccountNumberId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceAccountNumberId(sourceAccountNumberId: JsonField) = apply { + this.sourceAccountNumberId = sourceAccountNumberId + } + + /** Whether the transfer requires explicit approval via the dashboard or API. */ + fun requireApproval(requireApproval: Boolean) = + requireApproval(JsonField.of(requireApproval)) + + /** + * Sets [Builder.requireApproval] to an arbitrary JSON value. + * + * You should usually call [Builder.requireApproval] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requireApproval(requireApproval: JsonField) = apply { + this.requireApproval = requireApproval + } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .businessApplicationIdentifier() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantNamePrefix() + * .merchantPostalCode() + * .merchantState() + * .recipientName() + * .senderAddressCity() + * .senderAddressLine1() + * .senderAddressPostalCode() + * .senderAddressState() + * .senderName() + * .sourceAccountNumberId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("amount", amount), + checkRequired("businessApplicationIdentifier", businessApplicationIdentifier), + checkRequired("cardTokenId", cardTokenId), + checkRequired("merchantCategoryCode", merchantCategoryCode), + checkRequired("merchantCityName", merchantCityName), + checkRequired("merchantName", merchantName), + checkRequired("merchantNamePrefix", merchantNamePrefix), + checkRequired("merchantPostalCode", merchantPostalCode), + checkRequired("merchantState", merchantState), + checkRequired("recipientName", recipientName), + checkRequired("senderAddressCity", senderAddressCity), + checkRequired("senderAddressLine1", senderAddressLine1), + checkRequired("senderAddressPostalCode", senderAddressPostalCode), + checkRequired("senderAddressState", senderAddressState), + checkRequired("senderName", senderName), + checkRequired("sourceAccountNumberId", sourceAccountNumberId), + requireApproval, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + amount() + businessApplicationIdentifier().validate() + cardTokenId() + merchantCategoryCode() + merchantCityName() + merchantName() + merchantNamePrefix() + merchantPostalCode() + merchantState() + recipientName() + senderAddressCity() + senderAddressLine1() + senderAddressPostalCode() + senderAddressState() + senderName() + sourceAccountNumberId() + requireApproval() + 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 (amount.asKnown().isPresent) 1 else 0) + + (businessApplicationIdentifier.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardTokenId.asKnown().isPresent) 1 else 0) + + (if (merchantCategoryCode.asKnown().isPresent) 1 else 0) + + (if (merchantCityName.asKnown().isPresent) 1 else 0) + + (if (merchantName.asKnown().isPresent) 1 else 0) + + (if (merchantNamePrefix.asKnown().isPresent) 1 else 0) + + (if (merchantPostalCode.asKnown().isPresent) 1 else 0) + + (if (merchantState.asKnown().isPresent) 1 else 0) + + (if (recipientName.asKnown().isPresent) 1 else 0) + + (if (senderAddressCity.asKnown().isPresent) 1 else 0) + + (if (senderAddressLine1.asKnown().isPresent) 1 else 0) + + (if (senderAddressPostalCode.asKnown().isPresent) 1 else 0) + + (if (senderAddressState.asKnown().isPresent) 1 else 0) + + (if (senderName.asKnown().isPresent) 1 else 0) + + (if (sourceAccountNumberId.asKnown().isPresent) 1 else 0) + + (if (requireApproval.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + amount == other.amount && + businessApplicationIdentifier == other.businessApplicationIdentifier && + cardTokenId == other.cardTokenId && + merchantCategoryCode == other.merchantCategoryCode && + merchantCityName == other.merchantCityName && + merchantName == other.merchantName && + merchantNamePrefix == other.merchantNamePrefix && + merchantPostalCode == other.merchantPostalCode && + merchantState == other.merchantState && + recipientName == other.recipientName && + senderAddressCity == other.senderAddressCity && + senderAddressLine1 == other.senderAddressLine1 && + senderAddressPostalCode == other.senderAddressPostalCode && + senderAddressState == other.senderAddressState && + senderName == other.senderName && + sourceAccountNumberId == other.sourceAccountNumberId && + requireApproval == other.requireApproval && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + businessApplicationIdentifier, + cardTokenId, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantNamePrefix, + merchantPostalCode, + merchantState, + recipientName, + senderAddressCity, + senderAddressLine1, + senderAddressPostalCode, + senderAddressState, + senderName, + sourceAccountNumberId, + requireApproval, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{amount=$amount, businessApplicationIdentifier=$businessApplicationIdentifier, cardTokenId=$cardTokenId, merchantCategoryCode=$merchantCategoryCode, merchantCityName=$merchantCityName, merchantName=$merchantName, merchantNamePrefix=$merchantNamePrefix, merchantPostalCode=$merchantPostalCode, merchantState=$merchantState, recipientName=$recipientName, senderAddressCity=$senderAddressCity, senderAddressLine1=$senderAddressLine1, senderAddressPostalCode=$senderAddressPostalCode, senderAddressState=$senderAddressState, senderName=$senderName, sourceAccountNumberId=$sourceAccountNumberId, requireApproval=$requireApproval, additionalProperties=$additionalProperties}" + } + + /** + * The Business Application Identifier describes the type of transaction being performed. Your + * program must be approved for the specified Business Application Identifier in order to use + * it. + */ + class BusinessApplicationIdentifier + @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 { + + /** Account to Account */ + @JvmField val ACCOUNT_TO_ACCOUNT = of("account_to_account") + + /** Business to Business */ + @JvmField val BUSINESS_TO_BUSINESS = of("business_to_business") + + /** Money Transfer Bank Initiated */ + @JvmField val MONEY_TRANSFER_BANK_INITIATED = of("money_transfer_bank_initiated") + + /** Non-Card Bill Payment */ + @JvmField val NON_CARD_BILL_PAYMENT = of("non_card_bill_payment") + + /** Consumer Bill Payment */ + @JvmField val CONSUMER_BILL_PAYMENT = of("consumer_bill_payment") + + /** Card Bill Payment */ + @JvmField val CARD_BILL_PAYMENT = of("card_bill_payment") + + /** Funds Disbursement */ + @JvmField val FUNDS_DISBURSEMENT = of("funds_disbursement") + + /** Funds Transfer */ + @JvmField val FUNDS_TRANSFER = of("funds_transfer") + + /** Loyalty and Offers */ + @JvmField val LOYALTY_AND_OFFERS = of("loyalty_and_offers") + + /** Merchant Disbursement */ + @JvmField val MERCHANT_DISBURSEMENT = of("merchant_disbursement") + + /** Merchant Payment */ + @JvmField val MERCHANT_PAYMENT = of("merchant_payment") + + /** Person to Person */ + @JvmField val PERSON_TO_PERSON = of("person_to_person") + + /** Top Up */ + @JvmField val TOP_UP = of("top_up") + + /** Wallet Transfer */ + @JvmField val WALLET_TRANSFER = of("wallet_transfer") + + @JvmStatic fun of(value: String) = BusinessApplicationIdentifier(JsonField.of(value)) + } + + /** An enum containing [BusinessApplicationIdentifier]'s known values. */ + enum class Known { + /** Account to Account */ + ACCOUNT_TO_ACCOUNT, + /** Business to Business */ + BUSINESS_TO_BUSINESS, + /** Money Transfer Bank Initiated */ + MONEY_TRANSFER_BANK_INITIATED, + /** Non-Card Bill Payment */ + NON_CARD_BILL_PAYMENT, + /** Consumer Bill Payment */ + CONSUMER_BILL_PAYMENT, + /** Card Bill Payment */ + CARD_BILL_PAYMENT, + /** Funds Disbursement */ + FUNDS_DISBURSEMENT, + /** Funds Transfer */ + FUNDS_TRANSFER, + /** Loyalty and Offers */ + LOYALTY_AND_OFFERS, + /** Merchant Disbursement */ + MERCHANT_DISBURSEMENT, + /** Merchant Payment */ + MERCHANT_PAYMENT, + /** Person to Person */ + PERSON_TO_PERSON, + /** Top Up */ + TOP_UP, + /** Wallet Transfer */ + WALLET_TRANSFER, + } + + /** + * An enum containing [BusinessApplicationIdentifier]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BusinessApplicationIdentifier] 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 { + /** Account to Account */ + ACCOUNT_TO_ACCOUNT, + /** Business to Business */ + BUSINESS_TO_BUSINESS, + /** Money Transfer Bank Initiated */ + MONEY_TRANSFER_BANK_INITIATED, + /** Non-Card Bill Payment */ + NON_CARD_BILL_PAYMENT, + /** Consumer Bill Payment */ + CONSUMER_BILL_PAYMENT, + /** Card Bill Payment */ + CARD_BILL_PAYMENT, + /** Funds Disbursement */ + FUNDS_DISBURSEMENT, + /** Funds Transfer */ + FUNDS_TRANSFER, + /** Loyalty and Offers */ + LOYALTY_AND_OFFERS, + /** Merchant Disbursement */ + MERCHANT_DISBURSEMENT, + /** Merchant Payment */ + MERCHANT_PAYMENT, + /** Person to Person */ + PERSON_TO_PERSON, + /** Top Up */ + TOP_UP, + /** Wallet Transfer */ + WALLET_TRANSFER, + /** + * An enum member indicating that [BusinessApplicationIdentifier] 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) { + ACCOUNT_TO_ACCOUNT -> Value.ACCOUNT_TO_ACCOUNT + BUSINESS_TO_BUSINESS -> Value.BUSINESS_TO_BUSINESS + MONEY_TRANSFER_BANK_INITIATED -> Value.MONEY_TRANSFER_BANK_INITIATED + NON_CARD_BILL_PAYMENT -> Value.NON_CARD_BILL_PAYMENT + CONSUMER_BILL_PAYMENT -> Value.CONSUMER_BILL_PAYMENT + CARD_BILL_PAYMENT -> Value.CARD_BILL_PAYMENT + FUNDS_DISBURSEMENT -> Value.FUNDS_DISBURSEMENT + FUNDS_TRANSFER -> Value.FUNDS_TRANSFER + LOYALTY_AND_OFFERS -> Value.LOYALTY_AND_OFFERS + MERCHANT_DISBURSEMENT -> Value.MERCHANT_DISBURSEMENT + MERCHANT_PAYMENT -> Value.MERCHANT_PAYMENT + PERSON_TO_PERSON -> Value.PERSON_TO_PERSON + TOP_UP -> Value.TOP_UP + WALLET_TRANSFER -> Value.WALLET_TRANSFER + 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) { + ACCOUNT_TO_ACCOUNT -> Known.ACCOUNT_TO_ACCOUNT + BUSINESS_TO_BUSINESS -> Known.BUSINESS_TO_BUSINESS + MONEY_TRANSFER_BANK_INITIATED -> Known.MONEY_TRANSFER_BANK_INITIATED + NON_CARD_BILL_PAYMENT -> Known.NON_CARD_BILL_PAYMENT + CONSUMER_BILL_PAYMENT -> Known.CONSUMER_BILL_PAYMENT + CARD_BILL_PAYMENT -> Known.CARD_BILL_PAYMENT + FUNDS_DISBURSEMENT -> Known.FUNDS_DISBURSEMENT + FUNDS_TRANSFER -> Known.FUNDS_TRANSFER + LOYALTY_AND_OFFERS -> Known.LOYALTY_AND_OFFERS + MERCHANT_DISBURSEMENT -> Known.MERCHANT_DISBURSEMENT + MERCHANT_PAYMENT -> Known.MERCHANT_PAYMENT + PERSON_TO_PERSON -> Known.PERSON_TO_PERSON + TOP_UP -> Known.TOP_UP + WALLET_TRANSFER -> Known.WALLET_TRANSFER + else -> + throw IncreaseInvalidDataException( + "Unknown BusinessApplicationIdentifier: $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(): BusinessApplicationIdentifier = 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 BusinessApplicationIdentifier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardPushTransferCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPage.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPage.kt new file mode 100644 index 000000000..865cf24ad --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPage.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.increase.api.core.AutoPager +import com.increase.api.core.Page +import com.increase.api.core.checkRequired +import com.increase.api.services.blocking.CardPushTransferService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see CardPushTransferService.list */ +class CardPushTransferListPage +private constructor( + private val service: CardPushTransferService, + private val params: CardPushTransferListParams, + private val response: CardPushTransferListPageResponse, +) : Page { + + /** + * Delegates to [CardPushTransferListPageResponse], but gracefully handles missing data. + * + * @see CardPushTransferListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardPushTransferListPageResponse], but gracefully handles missing data. + * + * @see CardPushTransferListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardPushTransferListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CardPushTransferListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): CardPushTransferListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardPushTransferListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardPushTransferListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferListPage]. */ + class Builder internal constructor() { + + private var service: CardPushTransferService? = null + private var params: CardPushTransferListParams? = null + private var response: CardPushTransferListPageResponse? = null + + @JvmSynthetic + internal fun from(cardPushTransferListPage: CardPushTransferListPage) = apply { + service = cardPushTransferListPage.service + params = cardPushTransferListPage.params + response = cardPushTransferListPage.response + } + + fun service(service: CardPushTransferService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CardPushTransferListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardPushTransferListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CardPushTransferListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardPushTransferListPage = + CardPushTransferListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "CardPushTransferListPage{service=$service, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageAsync.kt new file mode 100644 index 000000000..603a9c2d0 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.increase.api.core.AutoPagerAsync +import com.increase.api.core.PageAsync +import com.increase.api.core.checkRequired +import com.increase.api.services.async.CardPushTransferServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see CardPushTransferServiceAsync.list */ +class CardPushTransferListPageAsync +private constructor( + private val service: CardPushTransferServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: CardPushTransferListParams, + private val response: CardPushTransferListPageResponse, +) : PageAsync { + + /** + * Delegates to [CardPushTransferListPageResponse], but gracefully handles missing data. + * + * @see CardPushTransferListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardPushTransferListPageResponse], but gracefully handles missing data. + * + * @see CardPushTransferListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardPushTransferListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): CardPushTransferListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardPushTransferListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CardPushTransferListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferListPageAsync]. */ + class Builder internal constructor() { + + private var service: CardPushTransferServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: CardPushTransferListParams? = null + private var response: CardPushTransferListPageResponse? = null + + @JvmSynthetic + internal fun from(cardPushTransferListPageAsync: CardPushTransferListPageAsync) = apply { + service = cardPushTransferListPageAsync.service + streamHandlerExecutor = cardPushTransferListPageAsync.streamHandlerExecutor + params = cardPushTransferListPageAsync.params + response = cardPushTransferListPageAsync.response + } + + fun service(service: CardPushTransferServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: CardPushTransferListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardPushTransferListPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [CardPushTransferListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardPushTransferListPageAsync = + CardPushTransferListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "CardPushTransferListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageResponse.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageResponse.kt new file mode 100644 index 000000000..daa1764dd --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageResponse.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +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.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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A list of Card Push Transfer objects. */ +class CardPushTransferListPageResponse +private constructor( + private val data: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + ) : this(data, nextCursor, mutableMapOf()) + + /** + * The contents of the list. + * + * @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 data(): List = data.getRequired("data") + + /** + * A pointer to a place in the list. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @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 + * [CardPushTransferListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardPushTransferListPageResponse: CardPushTransferListPageResponse) = + apply { + data = cardPushTransferListPageResponse.data.map { it.toMutableList() } + nextCursor = cardPushTransferListPageResponse.nextCursor + additionalProperties = + cardPushTransferListPageResponse.additionalProperties.toMutableMap() + } + + /** The contents of the list. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CardPushTransfer] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CardPushTransfer) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** A pointer to a place in the list. */ + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + /** Alias for calling [Builder.nextCursor] with `nextCursor.orElse(null)`. */ + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.getOrNull()) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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 [CardPushTransferListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardPushTransferListPageResponse = + CardPushTransferListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextCursor", nextCursor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardPushTransferListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextCursor() + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferListPageResponse && + data == other.data && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextCursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardPushTransferListPageResponse{data=$data, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListParams.kt new file mode 100644 index 000000000..5597a2fdb --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListParams.kt @@ -0,0 +1,830 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.fasterxml.jackson.annotation.JsonCreator +import com.increase.api.core.Enum +import com.increase.api.core.JsonField +import com.increase.api.core.Params +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.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Card Push Transfers */ +class CardPushTransferListParams +private constructor( + private val accountId: String?, + private val createdAt: CreatedAt?, + private val cursor: String?, + private val idempotencyKey: String?, + private val limit: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Filter Card Push Transfers to ones belonging to the specified Account. */ + fun accountId(): Optional = Optional.ofNullable(accountId) + + fun createdAt(): Optional = Optional.ofNullable(createdAt) + + /** Return the page of entries after this one. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only processed + * once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(): Optional = Optional.ofNullable(idempotencyKey) + + /** Limit the size of the list that is returned. The default (and maximum) is 100 objects. */ + fun limit(): Optional = Optional.ofNullable(limit) + + fun status(): Optional = Optional.ofNullable(status) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardPushTransferListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardPushTransferListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferListParams]. */ + class Builder internal constructor() { + + private var accountId: String? = null + private var createdAt: CreatedAt? = null + private var cursor: String? = null + private var idempotencyKey: String? = null + private var limit: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardPushTransferListParams: CardPushTransferListParams) = apply { + accountId = cardPushTransferListParams.accountId + createdAt = cardPushTransferListParams.createdAt + cursor = cardPushTransferListParams.cursor + idempotencyKey = cardPushTransferListParams.idempotencyKey + limit = cardPushTransferListParams.limit + status = cardPushTransferListParams.status + additionalHeaders = cardPushTransferListParams.additionalHeaders.toBuilder() + additionalQueryParams = cardPushTransferListParams.additionalQueryParams.toBuilder() + } + + /** Filter Card Push Transfers to ones belonging to the specified Account. */ + fun accountId(accountId: String?) = apply { this.accountId = accountId } + + /** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */ + fun accountId(accountId: Optional) = accountId(accountId.getOrNull()) + + fun createdAt(createdAt: CreatedAt?) = apply { this.createdAt = createdAt } + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** Return the page of entries after this one. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only + * processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = apply { this.idempotencyKey = idempotencyKey } + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Limit the size of the list that is returned. The default (and maximum) is 100 objects. + */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardPushTransferListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardPushTransferListParams = + CardPushTransferListParams( + accountId, + createdAt, + cursor, + idempotencyKey, + limit, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + accountId?.let { put("account_id", it) } + createdAt?.let { + it.after().ifPresent { + put("created_at.after", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.before().ifPresent { + put("created_at.before", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.onOrAfter().ifPresent { + put( + "created_at.on_or_after", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it.onOrBefore().ifPresent { + put( + "created_at.on_or_before", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("created_at.$key", value) + } + } + } + cursor?.let { put("cursor", it) } + idempotencyKey?.let { put("idempotency_key", it) } + limit?.let { put("limit", it.toString()) } + status?.let { + it.in_().ifPresent { put("status.in", it.joinToString(",") { it.toString() }) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("status.$key", value) + } + } + } + putAll(additionalQueryParams) + } + .build() + + class CreatedAt + private constructor( + private val after: OffsetDateTime?, + private val before: OffsetDateTime?, + private val onOrAfter: OffsetDateTime?, + private val onOrBefore: OffsetDateTime?, + private val additionalProperties: QueryParams, + ) { + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun after(): Optional = Optional.ofNullable(after) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun before(): Optional = Optional.ofNullable(before) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(): Optional = Optional.ofNullable(onOrAfter) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(): Optional = Optional.ofNullable(onOrBefore) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreatedAt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedAt]. */ + class Builder internal constructor() { + + private var after: OffsetDateTime? = null + private var before: OffsetDateTime? = null + private var onOrAfter: OffsetDateTime? = null + private var onOrBefore: OffsetDateTime? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(createdAt: CreatedAt) = apply { + after = createdAt.after + before = createdAt.before + onOrAfter = createdAt.onOrAfter + onOrBefore = createdAt.onOrBefore + additionalProperties = createdAt.additionalProperties.toBuilder() + } + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun after(after: OffsetDateTime?) = apply { this.after = after } + + /** Alias for calling [Builder.after] with `after.orElse(null)`. */ + fun after(after: Optional) = after(after.getOrNull()) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun before(before: OffsetDateTime?) = apply { this.before = before } + + /** Alias for calling [Builder.before] with `before.orElse(null)`. */ + fun before(before: Optional) = before(before.getOrNull()) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(onOrAfter: OffsetDateTime?) = apply { this.onOrAfter = onOrAfter } + + /** Alias for calling [Builder.onOrAfter] with `onOrAfter.orElse(null)`. */ + fun onOrAfter(onOrAfter: Optional) = onOrAfter(onOrAfter.getOrNull()) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(onOrBefore: OffsetDateTime?) = apply { this.onOrBefore = onOrBefore } + + /** Alias for calling [Builder.onOrBefore] with `onOrBefore.orElse(null)`. */ + fun onOrBefore(onOrBefore: Optional) = + onOrBefore(onOrBefore.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreatedAt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreatedAt = + CreatedAt(after, before, onOrAfter, onOrBefore, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedAt && + after == other.after && + before == other.before && + onOrAfter == other.onOrAfter && + onOrBefore == other.onOrBefore && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(after, before, onOrAfter, onOrBefore, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedAt{after=$after, before=$before, onOrAfter=$onOrAfter, onOrBefore=$onOrBefore, additionalProperties=$additionalProperties}" + } + + class Status + private constructor(private val in_: List?, private val additionalProperties: QueryParams) { + + /** + * Filter Card Push Transfers by status. For GET requests, this should be encoded as a + * comma-delimited string, such as `?in=one,two,three`. + */ + fun in_(): Optional> = Optional.ofNullable(in_) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Status]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var in_: MutableList? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(status: Status) = apply { + in_ = status.in_?.toMutableList() + additionalProperties = status.additionalProperties.toBuilder() + } + + /** + * Filter Card Push Transfers by status. For GET requests, this should be encoded as a + * comma-delimited string, such as `?in=one,two,three`. + */ + fun in_(in_: List?) = apply { this.in_ = in_?.toMutableList() } + + /** Alias for calling [Builder.in_] with `in_.orElse(null)`. */ + fun in_(in_: Optional>) = in_(in_.getOrNull()) + + /** + * Adds a single [In] to [Builder.in_]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIn(in_: In) = apply { + this.in_ = (this.in_ ?: mutableListOf()).apply { add(in_) } + } + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Status = Status(in_?.toImmutable(), additionalProperties.build()) + } + + class In @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 transfer is pending approval. */ + @JvmField val PENDING_APPROVAL = of("pending_approval") + + /** The transfer has been canceled. */ + @JvmField val CANCELED = of("canceled") + + /** The transfer is pending review by Increase. */ + @JvmField val PENDING_REVIEWING = of("pending_reviewing") + + /** The transfer requires attention from an Increase operator. */ + @JvmField val REQUIRES_ATTENTION = of("requires_attention") + + /** The transfer is queued to be submitted to the card network. */ + @JvmField val PENDING_SUBMISSION = of("pending_submission") + + /** + * The transfer has been submitted and is pending a response from the card network. + */ + @JvmField val SUBMITTED = of("submitted") + + /** The transfer has been sent successfully and is complete. */ + @JvmField val COMPLETE = of("complete") + + /** The transfer was declined by the network or the recipient's bank. */ + @JvmField val DECLINED = of("declined") + + @JvmStatic fun of(value: String) = In(JsonField.of(value)) + } + + /** An enum containing [In]'s known values. */ + enum class Known { + /** The transfer is pending approval. */ + PENDING_APPROVAL, + /** The transfer has been canceled. */ + CANCELED, + /** The transfer is pending review by Increase. */ + PENDING_REVIEWING, + /** The transfer requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The transfer is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** + * The transfer has been submitted and is pending a response from the card network. + */ + SUBMITTED, + /** The transfer has been sent successfully and is complete. */ + COMPLETE, + /** The transfer was declined by the network or the recipient's bank. */ + DECLINED, + } + + /** + * An enum containing [In]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [In] 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 transfer is pending approval. */ + PENDING_APPROVAL, + /** The transfer has been canceled. */ + CANCELED, + /** The transfer is pending review by Increase. */ + PENDING_REVIEWING, + /** The transfer requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The transfer is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** + * The transfer has been submitted and is pending a response from the card network. + */ + SUBMITTED, + /** The transfer has been sent successfully and is complete. */ + COMPLETE, + /** The transfer was declined by the network or the recipient's bank. */ + DECLINED, + /** An enum member indicating that [In] 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) { + PENDING_APPROVAL -> Value.PENDING_APPROVAL + CANCELED -> Value.CANCELED + PENDING_REVIEWING -> Value.PENDING_REVIEWING + REQUIRES_ATTENTION -> Value.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Value.PENDING_SUBMISSION + SUBMITTED -> Value.SUBMITTED + COMPLETE -> Value.COMPLETE + DECLINED -> Value.DECLINED + 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) { + PENDING_APPROVAL -> Known.PENDING_APPROVAL + CANCELED -> Known.CANCELED + PENDING_REVIEWING -> Known.PENDING_REVIEWING + REQUIRES_ATTENTION -> Known.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Known.PENDING_SUBMISSION + SUBMITTED -> Known.SUBMITTED + COMPLETE -> Known.COMPLETE + DECLINED -> Known.DECLINED + else -> throw IncreaseInvalidDataException("Unknown In: $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(): In = 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 In && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && + in_ == other.in_ && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(in_, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Status{in_=$in_, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferListParams && + accountId == other.accountId && + createdAt == other.createdAt && + cursor == other.cursor && + idempotencyKey == other.idempotencyKey && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + accountId, + createdAt, + cursor, + idempotencyKey, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CardPushTransferListParams{accountId=$accountId, createdAt=$createdAt, cursor=$cursor, idempotencyKey=$idempotencyKey, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferRetrieveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferRetrieveParams.kt new file mode 100644 index 000000000..7abf3d2e0 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferRetrieveParams.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a Card Push Transfer */ +class CardPushTransferRetrieveParams +private constructor( + private val cardPushTransferId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Push Transfer. */ + fun cardPushTransferId(): Optional = Optional.ofNullable(cardPushTransferId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardPushTransferRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CardPushTransferRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardPushTransferRetrieveParams]. */ + class Builder internal constructor() { + + private var cardPushTransferId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardPushTransferRetrieveParams: CardPushTransferRetrieveParams) = apply { + cardPushTransferId = cardPushTransferRetrieveParams.cardPushTransferId + additionalHeaders = cardPushTransferRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = cardPushTransferRetrieveParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Push Transfer. */ + fun cardPushTransferId(cardPushTransferId: String?) = apply { + this.cardPushTransferId = cardPushTransferId + } + + /** + * Alias for calling [Builder.cardPushTransferId] with `cardPushTransferId.orElse(null)`. + */ + fun cardPushTransferId(cardPushTransferId: Optional) = + cardPushTransferId(cardPushTransferId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardPushTransferRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardPushTransferRetrieveParams = + CardPushTransferRetrieveParams( + cardPushTransferId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardPushTransferId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardPushTransferRetrieveParams && + cardPushTransferId == other.cardPushTransferId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardPushTransferId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardPushTransferRetrieveParams{cardPushTransferId=$cardPushTransferId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardToken.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardToken.kt new file mode 100644 index 000000000..a5ac7295a --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardToken.kt @@ -0,0 +1,552 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +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.checkRequired +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Card Tokens represent a tokenized card number that can be used for Card Push Transfers and Card + * Validations. + */ +class CardToken +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val expirationDate: JsonField, + private val last4: JsonField, + private val length: JsonField, + private val prefix: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("expiration_date") + @ExcludeMissing + expirationDate: JsonField = JsonMissing.of(), + @JsonProperty("last4") @ExcludeMissing last4: JsonField = JsonMissing.of(), + @JsonProperty("length") @ExcludeMissing length: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, createdAt, expirationDate, last4, length, prefix, type, mutableMapOf()) + + /** + * The Card Token's identifier. + * + * @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 id(): String = id.getRequired("id") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the card token + * was created. + * + * @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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the card expires. + * + * @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 expirationDate(): LocalDate = expirationDate.getRequired("expiration_date") + + /** + * The last 4 digits of the card number. + * + * @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 last4(): String = last4.getRequired("last4") + + /** + * The length of the card number. + * + * @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 length(): Long = length.getRequired("length") + + /** + * The prefix of the card number, usually 8 digits. + * + * @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 prefix(): String = prefix.getRequired("prefix") + + /** + * A constant representing the object's type. For this resource it will always be `card_token`. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [expirationDate]. + * + * Unlike [expirationDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiration_date") + @ExcludeMissing + fun _expirationDate(): JsonField = expirationDate + + /** + * Returns the raw JSON value of [last4]. + * + * Unlike [last4], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last4") @ExcludeMissing fun _last4(): JsonField = last4 + + /** + * Returns the raw JSON value of [length]. + * + * Unlike [length], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("length") @ExcludeMissing fun _length(): JsonField = length + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 [CardToken]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .expirationDate() + * .last4() + * .length() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardToken]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var expirationDate: JsonField? = null + private var last4: JsonField? = null + private var length: JsonField? = null + private var prefix: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardToken: CardToken) = apply { + id = cardToken.id + createdAt = cardToken.createdAt + expirationDate = cardToken.expirationDate + last4 = cardToken.last4 + length = cardToken.length + prefix = cardToken.prefix + type = cardToken.type + additionalProperties = cardToken.additionalProperties.toMutableMap() + } + + /** The Card Token's identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the card + * token was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date when the card expires. */ + fun expirationDate(expirationDate: LocalDate) = expirationDate(JsonField.of(expirationDate)) + + /** + * Sets [Builder.expirationDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expirationDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expirationDate(expirationDate: JsonField) = apply { + this.expirationDate = expirationDate + } + + /** The last 4 digits of the card number. */ + fun last4(last4: String) = last4(JsonField.of(last4)) + + /** + * Sets [Builder.last4] to an arbitrary JSON value. + * + * You should usually call [Builder.last4] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun last4(last4: JsonField) = apply { this.last4 = last4 } + + /** The length of the card number. */ + fun length(length: Long) = length(JsonField.of(length)) + + /** + * Sets [Builder.length] to an arbitrary JSON value. + * + * You should usually call [Builder.length] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun length(length: JsonField) = apply { this.length = length } + + /** The prefix of the card number, usually 8 digits. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_token`. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [CardToken]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .expirationDate() + * .last4() + * .length() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardToken = + CardToken( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("expirationDate", expirationDate), + checkRequired("last4", last4), + checkRequired("length", length), + checkRequired("prefix", prefix), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardToken = apply { + if (validated) { + return@apply + } + + id() + createdAt() + expirationDate() + last4() + length() + prefix() + type().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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (expirationDate.asKnown().isPresent) 1 else 0) + + (if (last4.asKnown().isPresent) 1 else 0) + + (if (length.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** + * A constant representing the object's type. For this resource it will always be `card_token`. + */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD_TOKEN = of("card_token") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CARD_TOKEN + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD_TOKEN, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD_TOKEN -> Value.CARD_TOKEN + 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) { + CARD_TOKEN -> Known.CARD_TOKEN + else -> throw IncreaseInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardToken && + id == other.id && + createdAt == other.createdAt && + expirationDate == other.expirationDate && + last4 == other.last4 && + length == other.length && + prefix == other.prefix && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + expirationDate, + last4, + length, + prefix, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardToken{id=$id, createdAt=$createdAt, expirationDate=$expirationDate, last4=$last4, length=$length, prefix=$prefix, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilities.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilities.kt new file mode 100644 index 000000000..53acc60cb --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilities.kt @@ -0,0 +1,1048 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +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.checkKnown +import com.increase.api.core.checkRequired +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * The capabilities of a Card Token describe whether the card can be used for specific operations, + * such as Card Push Transfers. The capabilities can change over time based on the issuing bank's + * configuration of the card range. + */ +class CardTokenCapabilities +private constructor( + private val routes: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("routes") @ExcludeMissing routes: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(routes, type, mutableMapOf()) + + /** + * Each route represent a path e.g., a push transfer can take. + * + * @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 routes(): List = routes.getRequired("routes") + + /** + * A constant representing the object's type. For this resource it will always be + * `card_token_capabilities`. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [routes]. + * + * Unlike [routes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routes") @ExcludeMissing fun _routes(): JsonField> = routes + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 [CardTokenCapabilities]. + * + * The following fields are required: + * ```java + * .routes() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenCapabilities]. */ + class Builder internal constructor() { + + private var routes: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardTokenCapabilities: CardTokenCapabilities) = apply { + routes = cardTokenCapabilities.routes.map { it.toMutableList() } + type = cardTokenCapabilities.type + additionalProperties = cardTokenCapabilities.additionalProperties.toMutableMap() + } + + /** Each route represent a path e.g., a push transfer can take. */ + fun routes(routes: List) = routes(JsonField.of(routes)) + + /** + * Sets [Builder.routes] to an arbitrary JSON value. + * + * You should usually call [Builder.routes] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routes(routes: JsonField>) = apply { + this.routes = routes.map { it.toMutableList() } + } + + /** + * Adds a single [Route] to [routes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRoute(route: Route) = apply { + routes = + (routes ?: JsonField.of(mutableListOf())).also { + checkKnown("routes", it).add(route) + } + } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_token_capabilities`. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [CardTokenCapabilities]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .routes() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTokenCapabilities = + CardTokenCapabilities( + checkRequired("routes", routes).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTokenCapabilities = apply { + if (validated) { + return@apply + } + + routes().forEach { it.validate() } + type().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 = + (routes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Route + private constructor( + private val crossBorderPushTransfers: JsonField, + private val domesticPushTransfers: JsonField, + private val route: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cross_border_push_transfers") + @ExcludeMissing + crossBorderPushTransfers: JsonField = JsonMissing.of(), + @JsonProperty("domestic_push_transfers") + @ExcludeMissing + domesticPushTransfers: JsonField = JsonMissing.of(), + @JsonProperty("route") @ExcludeMissing route: JsonField = JsonMissing.of(), + ) : this(crossBorderPushTransfers, domesticPushTransfers, route, mutableMapOf()) + + /** + * Whether you can push funds to the card using cross-border Card Push Transfers. + * + * @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 crossBorderPushTransfers(): CrossBorderPushTransfers = + crossBorderPushTransfers.getRequired("cross_border_push_transfers") + + /** + * Whether you can push funds to the card using domestic Card Push Transfers. + * + * @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 domesticPushTransfers(): DomesticPushTransfers = + domesticPushTransfers.getRequired("domestic_push_transfers") + + /** + * The card network route the capabilities apply to. + * + * @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 route(): InnerRoute = route.getRequired("route") + + /** + * Returns the raw JSON value of [crossBorderPushTransfers]. + * + * Unlike [crossBorderPushTransfers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cross_border_push_transfers") + @ExcludeMissing + fun _crossBorderPushTransfers(): JsonField = + crossBorderPushTransfers + + /** + * Returns the raw JSON value of [domesticPushTransfers]. + * + * Unlike [domesticPushTransfers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("domestic_push_transfers") + @ExcludeMissing + fun _domesticPushTransfers(): JsonField = domesticPushTransfers + + /** + * Returns the raw JSON value of [route]. + * + * Unlike [route], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("route") @ExcludeMissing fun _route(): JsonField = route + + @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 [Route]. + * + * The following fields are required: + * ```java + * .crossBorderPushTransfers() + * .domesticPushTransfers() + * .route() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Route]. */ + class Builder internal constructor() { + + private var crossBorderPushTransfers: JsonField? = null + private var domesticPushTransfers: JsonField? = null + private var route: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(route: Route) = apply { + crossBorderPushTransfers = route.crossBorderPushTransfers + domesticPushTransfers = route.domesticPushTransfers + this.route = route.route + additionalProperties = route.additionalProperties.toMutableMap() + } + + /** Whether you can push funds to the card using cross-border Card Push Transfers. */ + fun crossBorderPushTransfers(crossBorderPushTransfers: CrossBorderPushTransfers) = + crossBorderPushTransfers(JsonField.of(crossBorderPushTransfers)) + + /** + * Sets [Builder.crossBorderPushTransfers] to an arbitrary JSON value. + * + * You should usually call [Builder.crossBorderPushTransfers] with a well-typed + * [CrossBorderPushTransfers] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun crossBorderPushTransfers( + crossBorderPushTransfers: JsonField + ) = apply { this.crossBorderPushTransfers = crossBorderPushTransfers } + + /** Whether you can push funds to the card using domestic Card Push Transfers. */ + fun domesticPushTransfers(domesticPushTransfers: DomesticPushTransfers) = + domesticPushTransfers(JsonField.of(domesticPushTransfers)) + + /** + * Sets [Builder.domesticPushTransfers] to an arbitrary JSON value. + * + * You should usually call [Builder.domesticPushTransfers] with a well-typed + * [DomesticPushTransfers] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun domesticPushTransfers(domesticPushTransfers: JsonField) = + apply { + this.domesticPushTransfers = domesticPushTransfers + } + + /** The card network route the capabilities apply to. */ + fun route(route: InnerRoute) = route(JsonField.of(route)) + + /** + * Sets [Builder.route] to an arbitrary JSON value. + * + * You should usually call [Builder.route] with a well-typed [InnerRoute] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun route(route: JsonField) = apply { this.route = route } + + 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 [Route]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .crossBorderPushTransfers() + * .domesticPushTransfers() + * .route() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Route = + Route( + checkRequired("crossBorderPushTransfers", crossBorderPushTransfers), + checkRequired("domesticPushTransfers", domesticPushTransfers), + checkRequired("route", route), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Route = apply { + if (validated) { + return@apply + } + + crossBorderPushTransfers().validate() + domesticPushTransfers().validate() + route().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 = + (crossBorderPushTransfers.asKnown().getOrNull()?.validity() ?: 0) + + (domesticPushTransfers.asKnown().getOrNull()?.validity() ?: 0) + + (route.asKnown().getOrNull()?.validity() ?: 0) + + /** Whether you can push funds to the card using cross-border Card Push Transfers. */ + class CrossBorderPushTransfers + @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 capability is supported. */ + @JvmField val SUPPORTED = of("supported") + + /** The capability is not supported. */ + @JvmField val NOT_SUPPORTED = of("not_supported") + + @JvmStatic fun of(value: String) = CrossBorderPushTransfers(JsonField.of(value)) + } + + /** An enum containing [CrossBorderPushTransfers]'s known values. */ + enum class Known { + /** The capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + } + + /** + * An enum containing [CrossBorderPushTransfers]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CrossBorderPushTransfers] 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 capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + /** + * An enum member indicating that [CrossBorderPushTransfers] 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) { + SUPPORTED -> Value.SUPPORTED + NOT_SUPPORTED -> Value.NOT_SUPPORTED + 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) { + SUPPORTED -> Known.SUPPORTED + NOT_SUPPORTED -> Known.NOT_SUPPORTED + else -> + throw IncreaseInvalidDataException( + "Unknown CrossBorderPushTransfers: $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(): CrossBorderPushTransfers = 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 CrossBorderPushTransfers && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Whether you can push funds to the card using domestic Card Push Transfers. */ + class DomesticPushTransfers + @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 capability is supported. */ + @JvmField val SUPPORTED = of("supported") + + /** The capability is not supported. */ + @JvmField val NOT_SUPPORTED = of("not_supported") + + @JvmStatic fun of(value: String) = DomesticPushTransfers(JsonField.of(value)) + } + + /** An enum containing [DomesticPushTransfers]'s known values. */ + enum class Known { + /** The capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + } + + /** + * An enum containing [DomesticPushTransfers]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DomesticPushTransfers] 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 capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + /** + * An enum member indicating that [DomesticPushTransfers] 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) { + SUPPORTED -> Value.SUPPORTED + NOT_SUPPORTED -> Value.NOT_SUPPORTED + 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) { + SUPPORTED -> Known.SUPPORTED + NOT_SUPPORTED -> Known.NOT_SUPPORTED + else -> + throw IncreaseInvalidDataException("Unknown DomesticPushTransfers: $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(): DomesticPushTransfers = 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 DomesticPushTransfers && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The card network route the capabilities apply to. */ + class InnerRoute @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 { + + /** Visa and Interlink */ + @JvmField val VISA = of("visa") + + /** Mastercard and Maestro */ + @JvmField val MASTERCARD = of("mastercard") + + @JvmStatic fun of(value: String) = InnerRoute(JsonField.of(value)) + } + + /** An enum containing [InnerRoute]'s known values. */ + enum class Known { + /** Visa and Interlink */ + VISA, + /** Mastercard and Maestro */ + MASTERCARD, + } + + /** + * An enum containing [InnerRoute]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InnerRoute] 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 { + /** Visa and Interlink */ + VISA, + /** Mastercard and Maestro */ + MASTERCARD, + /** + * An enum member indicating that [InnerRoute] 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) { + VISA -> Value.VISA + MASTERCARD -> Value.MASTERCARD + 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) { + VISA -> Known.VISA + MASTERCARD -> Known.MASTERCARD + else -> throw IncreaseInvalidDataException("Unknown InnerRoute: $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(): InnerRoute = 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 InnerRoute && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Route && + crossBorderPushTransfers == other.crossBorderPushTransfers && + domesticPushTransfers == other.domesticPushTransfers && + route == other.route && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + crossBorderPushTransfers, + domesticPushTransfers, + route, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Route{crossBorderPushTransfers=$crossBorderPushTransfers, domesticPushTransfers=$domesticPushTransfers, route=$route, additionalProperties=$additionalProperties}" + } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_token_capabilities`. + */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD_TOKEN_CAPABILITIES = of("card_token_capabilities") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CARD_TOKEN_CAPABILITIES + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD_TOKEN_CAPABILITIES, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD_TOKEN_CAPABILITIES -> Value.CARD_TOKEN_CAPABILITIES + 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) { + CARD_TOKEN_CAPABILITIES -> Known.CARD_TOKEN_CAPABILITIES + else -> throw IncreaseInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenCapabilities && + routes == other.routes && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(routes, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTokenCapabilities{routes=$routes, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesParams.kt new file mode 100644 index 000000000..8aa9b7d2a --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesParams.kt @@ -0,0 +1,202 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * The capabilities of a Card Token describe whether the card can be used for specific operations, + * such as Card Push Transfers. The capabilities can change over time based on the issuing bank's + * configuration of the card range. + */ +class CardTokenCapabilitiesParams +private constructor( + private val cardTokenId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Token. */ + fun cardTokenId(): Optional = Optional.ofNullable(cardTokenId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardTokenCapabilitiesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardTokenCapabilitiesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenCapabilitiesParams]. */ + class Builder internal constructor() { + + private var cardTokenId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardTokenCapabilitiesParams: CardTokenCapabilitiesParams) = apply { + cardTokenId = cardTokenCapabilitiesParams.cardTokenId + additionalHeaders = cardTokenCapabilitiesParams.additionalHeaders.toBuilder() + additionalQueryParams = cardTokenCapabilitiesParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Token. */ + fun cardTokenId(cardTokenId: String?) = apply { this.cardTokenId = cardTokenId } + + /** Alias for calling [Builder.cardTokenId] with `cardTokenId.orElse(null)`. */ + fun cardTokenId(cardTokenId: Optional) = cardTokenId(cardTokenId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardTokenCapabilitiesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardTokenCapabilitiesParams = + CardTokenCapabilitiesParams( + cardTokenId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardTokenId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenCapabilitiesParams && + cardTokenId == other.cardTokenId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardTokenId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardTokenCapabilitiesParams{cardTokenId=$cardTokenId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPage.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPage.kt new file mode 100644 index 000000000..1c7dfc628 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPage.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.increase.api.core.AutoPager +import com.increase.api.core.Page +import com.increase.api.core.checkRequired +import com.increase.api.services.blocking.CardTokenService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see CardTokenService.list */ +class CardTokenListPage +private constructor( + private val service: CardTokenService, + private val params: CardTokenListParams, + private val response: CardTokenListPageResponse, +) : Page { + + /** + * Delegates to [CardTokenListPageResponse], but gracefully handles missing data. + * + * @see CardTokenListPageResponse.data + */ + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardTokenListPageResponse], but gracefully handles missing data. + * + * @see CardTokenListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardTokenListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CardTokenListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): CardTokenListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardTokenListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardTokenListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenListPage]. */ + class Builder internal constructor() { + + private var service: CardTokenService? = null + private var params: CardTokenListParams? = null + private var response: CardTokenListPageResponse? = null + + @JvmSynthetic + internal fun from(cardTokenListPage: CardTokenListPage) = apply { + service = cardTokenListPage.service + params = cardTokenListPage.params + response = cardTokenListPage.response + } + + fun service(service: CardTokenService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CardTokenListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardTokenListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardTokenListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTokenListPage = + CardTokenListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "CardTokenListPage{service=$service, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPageAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPageAsync.kt new file mode 100644 index 000000000..e1b562f8d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPageAsync.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.increase.api.core.AutoPagerAsync +import com.increase.api.core.PageAsync +import com.increase.api.core.checkRequired +import com.increase.api.services.async.CardTokenServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see CardTokenServiceAsync.list */ +class CardTokenListPageAsync +private constructor( + private val service: CardTokenServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: CardTokenListParams, + private val response: CardTokenListPageResponse, +) : PageAsync { + + /** + * Delegates to [CardTokenListPageResponse], but gracefully handles missing data. + * + * @see CardTokenListPageResponse.data + */ + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardTokenListPageResponse], but gracefully handles missing data. + * + * @see CardTokenListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardTokenListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): CardTokenListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardTokenListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardTokenListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenListPageAsync]. */ + class Builder internal constructor() { + + private var service: CardTokenServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: CardTokenListParams? = null + private var response: CardTokenListPageResponse? = null + + @JvmSynthetic + internal fun from(cardTokenListPageAsync: CardTokenListPageAsync) = apply { + service = cardTokenListPageAsync.service + streamHandlerExecutor = cardTokenListPageAsync.streamHandlerExecutor + params = cardTokenListPageAsync.params + response = cardTokenListPageAsync.response + } + + fun service(service: CardTokenServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: CardTokenListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardTokenListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardTokenListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTokenListPageAsync = + CardTokenListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "CardTokenListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPageResponse.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPageResponse.kt new file mode 100644 index 000000000..4d0230e01 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListPageResponse.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +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.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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A list of Card Token objects. */ +class CardTokenListPageResponse +private constructor( + private val data: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + ) : this(data, nextCursor, mutableMapOf()) + + /** + * The contents of the list. + * + * @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 data(): List = data.getRequired("data") + + /** + * A pointer to a place in the list. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @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 [CardTokenListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardTokenListPageResponse: CardTokenListPageResponse) = apply { + data = cardTokenListPageResponse.data.map { it.toMutableList() } + nextCursor = cardTokenListPageResponse.nextCursor + additionalProperties = cardTokenListPageResponse.additionalProperties.toMutableMap() + } + + /** The contents of the list. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CardToken] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CardToken) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** A pointer to a place in the list. */ + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + /** Alias for calling [Builder.nextCursor] with `nextCursor.orElse(null)`. */ + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.getOrNull()) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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 [CardTokenListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTokenListPageResponse = + CardTokenListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextCursor", nextCursor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTokenListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextCursor() + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenListPageResponse && + data == other.data && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextCursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTokenListPageResponse{data=$data, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListParams.kt new file mode 100644 index 000000000..b3aa4a113 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenListParams.kt @@ -0,0 +1,437 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Card Tokens */ +class CardTokenListParams +private constructor( + private val createdAt: CreatedAt?, + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun createdAt(): Optional = Optional.ofNullable(createdAt) + + /** Return the page of entries after this one. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Limit the size of the list that is returned. The default (and maximum) is 100 objects. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardTokenListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CardTokenListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenListParams]. */ + class Builder internal constructor() { + + private var createdAt: CreatedAt? = null + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardTokenListParams: CardTokenListParams) = apply { + createdAt = cardTokenListParams.createdAt + cursor = cardTokenListParams.cursor + limit = cardTokenListParams.limit + additionalHeaders = cardTokenListParams.additionalHeaders.toBuilder() + additionalQueryParams = cardTokenListParams.additionalQueryParams.toBuilder() + } + + fun createdAt(createdAt: CreatedAt?) = apply { this.createdAt = createdAt } + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** Return the page of entries after this one. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Limit the size of the list that is returned. The default (and maximum) is 100 objects. + */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardTokenListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardTokenListParams = + CardTokenListParams( + createdAt, + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + createdAt?.let { + it.after().ifPresent { + put("created_at.after", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.before().ifPresent { + put("created_at.before", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.onOrAfter().ifPresent { + put( + "created_at.on_or_after", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it.onOrBefore().ifPresent { + put( + "created_at.on_or_before", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("created_at.$key", value) + } + } + } + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class CreatedAt + private constructor( + private val after: OffsetDateTime?, + private val before: OffsetDateTime?, + private val onOrAfter: OffsetDateTime?, + private val onOrBefore: OffsetDateTime?, + private val additionalProperties: QueryParams, + ) { + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun after(): Optional = Optional.ofNullable(after) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun before(): Optional = Optional.ofNullable(before) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(): Optional = Optional.ofNullable(onOrAfter) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(): Optional = Optional.ofNullable(onOrBefore) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreatedAt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedAt]. */ + class Builder internal constructor() { + + private var after: OffsetDateTime? = null + private var before: OffsetDateTime? = null + private var onOrAfter: OffsetDateTime? = null + private var onOrBefore: OffsetDateTime? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(createdAt: CreatedAt) = apply { + after = createdAt.after + before = createdAt.before + onOrAfter = createdAt.onOrAfter + onOrBefore = createdAt.onOrBefore + additionalProperties = createdAt.additionalProperties.toBuilder() + } + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun after(after: OffsetDateTime?) = apply { this.after = after } + + /** Alias for calling [Builder.after] with `after.orElse(null)`. */ + fun after(after: Optional) = after(after.getOrNull()) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun before(before: OffsetDateTime?) = apply { this.before = before } + + /** Alias for calling [Builder.before] with `before.orElse(null)`. */ + fun before(before: Optional) = before(before.getOrNull()) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(onOrAfter: OffsetDateTime?) = apply { this.onOrAfter = onOrAfter } + + /** Alias for calling [Builder.onOrAfter] with `onOrAfter.orElse(null)`. */ + fun onOrAfter(onOrAfter: Optional) = onOrAfter(onOrAfter.getOrNull()) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(onOrBefore: OffsetDateTime?) = apply { this.onOrBefore = onOrBefore } + + /** Alias for calling [Builder.onOrBefore] with `onOrBefore.orElse(null)`. */ + fun onOrBefore(onOrBefore: Optional) = + onOrBefore(onOrBefore.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreatedAt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreatedAt = + CreatedAt(after, before, onOrAfter, onOrBefore, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedAt && + after == other.after && + before == other.before && + onOrAfter == other.onOrAfter && + onOrBefore == other.onOrBefore && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(after, before, onOrAfter, onOrBefore, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedAt{after=$after, before=$before, onOrAfter=$onOrAfter, onOrBefore=$onOrBefore, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenListParams && + createdAt == other.createdAt && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(createdAt, cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardTokenListParams{createdAt=$createdAt, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenRetrieveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenRetrieveParams.kt new file mode 100644 index 000000000..383f6c990 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardtokens/CardTokenRetrieveParams.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a Card Token */ +class CardTokenRetrieveParams +private constructor( + private val cardTokenId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Token. */ + fun cardTokenId(): Optional = Optional.ofNullable(cardTokenId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardTokenRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CardTokenRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenRetrieveParams]. */ + class Builder internal constructor() { + + private var cardTokenId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardTokenRetrieveParams: CardTokenRetrieveParams) = apply { + cardTokenId = cardTokenRetrieveParams.cardTokenId + additionalHeaders = cardTokenRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = cardTokenRetrieveParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Token. */ + fun cardTokenId(cardTokenId: String?) = apply { this.cardTokenId = cardTokenId } + + /** Alias for calling [Builder.cardTokenId] with `cardTokenId.orElse(null)`. */ + fun cardTokenId(cardTokenId: Optional) = cardTokenId(cardTokenId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardTokenRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardTokenRetrieveParams = + CardTokenRetrieveParams( + cardTokenId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardTokenId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenRetrieveParams && + cardTokenId == other.cardTokenId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardTokenId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardTokenRetrieveParams{cardTokenId=$cardTokenId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidation.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidation.kt new file mode 100644 index 000000000..d1ae169b3 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidation.kt @@ -0,0 +1,5257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +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.checkRequired +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Card Validations are used to validate a card and its cardholder before sending funds to or + * pulling funds from a card. + */ +class CardValidation +private constructor( + private val id: JsonField, + private val acceptance: JsonField, + private val accountId: JsonField, + private val cardholderFirstName: JsonField, + private val cardholderLastName: JsonField, + private val cardholderMiddleName: JsonField, + private val cardholderPostalCode: JsonField, + private val cardholderStreetAddress: JsonField, + private val createdAt: JsonField, + private val createdBy: JsonField, + private val decline: JsonField, + private val idempotencyKey: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCityName: JsonField, + private val merchantName: JsonField, + private val merchantPostalCode: JsonField, + private val merchantState: JsonField, + private val status: JsonField, + private val submission: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("acceptance") + @ExcludeMissing + acceptance: JsonField = JsonMissing.of(), + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_first_name") + @ExcludeMissing + cardholderFirstName: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_last_name") + @ExcludeMissing + cardholderLastName: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_middle_name") + @ExcludeMissing + cardholderMiddleName: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_postal_code") + @ExcludeMissing + cardholderPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_street_address") + @ExcludeMissing + cardholderStreetAddress: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField = JsonMissing.of(), + @JsonProperty("decline") @ExcludeMissing decline: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_key") + @ExcludeMissing + idempotencyKey: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_city_name") + @ExcludeMissing + merchantCityName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name") + @ExcludeMissing + merchantName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_postal_code") + @ExcludeMissing + merchantPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_state") + @ExcludeMissing + merchantState: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("submission") + @ExcludeMissing + submission: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + acceptance, + accountId, + cardholderFirstName, + cardholderLastName, + cardholderMiddleName, + cardholderPostalCode, + cardholderStreetAddress, + createdAt, + createdBy, + decline, + idempotencyKey, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantPostalCode, + merchantState, + status, + submission, + type, + mutableMapOf(), + ) + + /** + * The Card Validation's identifier. + * + * @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 id(): String = id.getRequired("id") + + /** + * If the validation is accepted by the recipient bank, this will contain supplemental details. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun acceptance(): Optional = acceptance.getOptional("acceptance") + + /** + * The identifier of the Account from which to send the validation. + * + * @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 accountId(): String = accountId.getRequired("account_id") + + /** + * The cardholder's first name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderFirstName(): Optional = + cardholderFirstName.getOptional("cardholder_first_name") + + /** + * The cardholder's last name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderLastName(): Optional = + cardholderLastName.getOptional("cardholder_last_name") + + /** + * The cardholder's middle name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderMiddleName(): Optional = + cardholderMiddleName.getOptional("cardholder_middle_name") + + /** + * The postal code of the cardholder's address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderPostalCode(): Optional = + cardholderPostalCode.getOptional("cardholder_postal_code") + + /** + * The cardholder's street address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderStreetAddress(): Optional = + cardholderStreetAddress.getOptional("cardholder_street_address") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the validation + * was created. + * + * @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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * What object created the validation, either via the API or the dashboard. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdBy(): Optional = createdBy.getOptional("created_by") + + /** + * If the validation is rejected by the card network or the destination financial institution, + * this will contain supplemental details. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun decline(): Optional = decline.getOptional("decline") + + /** + * The idempotency key you chose for this object. This value is unique across Increase and is + * used to ensure that a request is only processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun idempotencyKey(): Optional = idempotencyKey.getOptional("idempotency_key") + + /** + * A four-digit code (MCC) identifying the type of business or service provided by the merchant. + * + * @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 merchantCategoryCode(): String = merchantCategoryCode.getRequired("merchant_category_code") + + /** + * The city where the merchant (typically your business) is located. + * + * @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 merchantCityName(): String = merchantCityName.getRequired("merchant_city_name") + + /** + * The merchant name that will appear in the cardholder’s statement descriptor. Typically your + * business name. + * + * @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 merchantName(): String = merchantName.getRequired("merchant_name") + + /** + * The postal code for the merchant’s (typically your business’s) location. + * + * @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 merchantPostalCode(): String = merchantPostalCode.getRequired("merchant_postal_code") + + /** + * The U.S. state where the merchant (typically your business) is located. + * + * @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 merchantState(): String = merchantState.getRequired("merchant_state") + + /** + * The lifecycle status of the validation. + * + * @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 status(): Status = status.getRequired("status") + + /** + * After the validation is submitted to the card network, this will contain supplemental + * details. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun submission(): Optional = submission.getOptional("submission") + + /** + * A constant representing the object's type. For this resource it will always be + * `card_validation`. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [acceptance]. + * + * Unlike [acceptance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("acceptance") + @ExcludeMissing + fun _acceptance(): JsonField = acceptance + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [cardholderFirstName]. + * + * Unlike [cardholderFirstName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cardholder_first_name") + @ExcludeMissing + fun _cardholderFirstName(): JsonField = cardholderFirstName + + /** + * Returns the raw JSON value of [cardholderLastName]. + * + * Unlike [cardholderLastName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cardholder_last_name") + @ExcludeMissing + fun _cardholderLastName(): JsonField = cardholderLastName + + /** + * Returns the raw JSON value of [cardholderMiddleName]. + * + * Unlike [cardholderMiddleName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cardholder_middle_name") + @ExcludeMissing + fun _cardholderMiddleName(): JsonField = cardholderMiddleName + + /** + * Returns the raw JSON value of [cardholderPostalCode]. + * + * Unlike [cardholderPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cardholder_postal_code") + @ExcludeMissing + fun _cardholderPostalCode(): JsonField = cardholderPostalCode + + /** + * Returns the raw JSON value of [cardholderStreetAddress]. + * + * Unlike [cardholderStreetAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_street_address") + @ExcludeMissing + fun _cardholderStreetAddress(): JsonField = cardholderStreetAddress + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [createdBy]. + * + * Unlike [createdBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_by") @ExcludeMissing fun _createdBy(): JsonField = createdBy + + /** + * Returns the raw JSON value of [decline]. + * + * Unlike [decline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("decline") @ExcludeMissing fun _decline(): JsonField = decline + + /** + * Returns the raw JSON value of [idempotencyKey]. + * + * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("idempotency_key") + @ExcludeMissing + fun _idempotencyKey(): JsonField = idempotencyKey + + /** + * 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 [merchantCityName]. + * + * Unlike [merchantCityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_city_name") + @ExcludeMissing + fun _merchantCityName(): JsonField = merchantCityName + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant_name") + @ExcludeMissing + fun _merchantName(): JsonField = merchantName + + /** + * Returns the raw JSON value of [merchantPostalCode]. + * + * Unlike [merchantPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_postal_code") + @ExcludeMissing + fun _merchantPostalCode(): JsonField = merchantPostalCode + + /** + * Returns the raw JSON value of [merchantState]. + * + * Unlike [merchantState], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant_state") + @ExcludeMissing + fun _merchantState(): JsonField = merchantState + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [submission]. + * + * Unlike [submission], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("submission") + @ExcludeMissing + fun _submission(): JsonField = submission + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 [CardValidation]. + * + * The following fields are required: + * ```java + * .id() + * .acceptance() + * .accountId() + * .cardholderFirstName() + * .cardholderLastName() + * .cardholderMiddleName() + * .cardholderPostalCode() + * .cardholderStreetAddress() + * .createdAt() + * .createdBy() + * .decline() + * .idempotencyKey() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantPostalCode() + * .merchantState() + * .status() + * .submission() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidation]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var acceptance: JsonField? = null + private var accountId: JsonField? = null + private var cardholderFirstName: JsonField? = null + private var cardholderLastName: JsonField? = null + private var cardholderMiddleName: JsonField? = null + private var cardholderPostalCode: JsonField? = null + private var cardholderStreetAddress: JsonField? = null + private var createdAt: JsonField? = null + private var createdBy: JsonField? = null + private var decline: JsonField? = null + private var idempotencyKey: JsonField? = null + private var merchantCategoryCode: JsonField? = null + private var merchantCityName: JsonField? = null + private var merchantName: JsonField? = null + private var merchantPostalCode: JsonField? = null + private var merchantState: JsonField? = null + private var status: JsonField? = null + private var submission: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardValidation: CardValidation) = apply { + id = cardValidation.id + acceptance = cardValidation.acceptance + accountId = cardValidation.accountId + cardholderFirstName = cardValidation.cardholderFirstName + cardholderLastName = cardValidation.cardholderLastName + cardholderMiddleName = cardValidation.cardholderMiddleName + cardholderPostalCode = cardValidation.cardholderPostalCode + cardholderStreetAddress = cardValidation.cardholderStreetAddress + createdAt = cardValidation.createdAt + createdBy = cardValidation.createdBy + decline = cardValidation.decline + idempotencyKey = cardValidation.idempotencyKey + merchantCategoryCode = cardValidation.merchantCategoryCode + merchantCityName = cardValidation.merchantCityName + merchantName = cardValidation.merchantName + merchantPostalCode = cardValidation.merchantPostalCode + merchantState = cardValidation.merchantState + status = cardValidation.status + submission = cardValidation.submission + type = cardValidation.type + additionalProperties = cardValidation.additionalProperties.toMutableMap() + } + + /** The Card Validation's identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * If the validation is accepted by the recipient bank, this will contain supplemental + * details. + */ + fun acceptance(acceptance: Acceptance?) = acceptance(JsonField.ofNullable(acceptance)) + + /** Alias for calling [Builder.acceptance] with `acceptance.orElse(null)`. */ + fun acceptance(acceptance: Optional) = acceptance(acceptance.getOrNull()) + + /** + * Sets [Builder.acceptance] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptance] with a well-typed [Acceptance] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptance(acceptance: JsonField) = apply { this.acceptance = acceptance } + + /** The identifier of the Account from which to send the validation. */ + fun accountId(accountId: String) = accountId(JsonField.of(accountId)) + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountId(accountId: JsonField) = apply { this.accountId = accountId } + + /** The cardholder's first name. */ + fun cardholderFirstName(cardholderFirstName: String?) = + cardholderFirstName(JsonField.ofNullable(cardholderFirstName)) + + /** + * Alias for calling [Builder.cardholderFirstName] with `cardholderFirstName.orElse(null)`. + */ + fun cardholderFirstName(cardholderFirstName: Optional) = + cardholderFirstName(cardholderFirstName.getOrNull()) + + /** + * Sets [Builder.cardholderFirstName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderFirstName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderFirstName(cardholderFirstName: JsonField) = apply { + this.cardholderFirstName = cardholderFirstName + } + + /** The cardholder's last name. */ + fun cardholderLastName(cardholderLastName: String?) = + cardholderLastName(JsonField.ofNullable(cardholderLastName)) + + /** + * Alias for calling [Builder.cardholderLastName] with `cardholderLastName.orElse(null)`. + */ + fun cardholderLastName(cardholderLastName: Optional) = + cardholderLastName(cardholderLastName.getOrNull()) + + /** + * Sets [Builder.cardholderLastName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderLastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderLastName(cardholderLastName: JsonField) = apply { + this.cardholderLastName = cardholderLastName + } + + /** The cardholder's middle name. */ + fun cardholderMiddleName(cardholderMiddleName: String?) = + cardholderMiddleName(JsonField.ofNullable(cardholderMiddleName)) + + /** + * Alias for calling [Builder.cardholderMiddleName] with + * `cardholderMiddleName.orElse(null)`. + */ + fun cardholderMiddleName(cardholderMiddleName: Optional) = + cardholderMiddleName(cardholderMiddleName.getOrNull()) + + /** + * Sets [Builder.cardholderMiddleName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderMiddleName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderMiddleName(cardholderMiddleName: JsonField) = apply { + this.cardholderMiddleName = cardholderMiddleName + } + + /** The postal code of the cardholder's address. */ + fun cardholderPostalCode(cardholderPostalCode: String?) = + cardholderPostalCode(JsonField.ofNullable(cardholderPostalCode)) + + /** + * Alias for calling [Builder.cardholderPostalCode] with + * `cardholderPostalCode.orElse(null)`. + */ + fun cardholderPostalCode(cardholderPostalCode: Optional) = + cardholderPostalCode(cardholderPostalCode.getOrNull()) + + /** + * Sets [Builder.cardholderPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderPostalCode(cardholderPostalCode: JsonField) = apply { + this.cardholderPostalCode = cardholderPostalCode + } + + /** The cardholder's street address. */ + fun cardholderStreetAddress(cardholderStreetAddress: String?) = + cardholderStreetAddress(JsonField.ofNullable(cardholderStreetAddress)) + + /** + * Alias for calling [Builder.cardholderStreetAddress] with + * `cardholderStreetAddress.orElse(null)`. + */ + fun cardholderStreetAddress(cardholderStreetAddress: Optional) = + cardholderStreetAddress(cardholderStreetAddress.getOrNull()) + + /** + * Sets [Builder.cardholderStreetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderStreetAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cardholderStreetAddress(cardholderStreetAddress: JsonField) = apply { + this.cardholderStreetAddress = cardholderStreetAddress + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** What object created the validation, either via the API or the dashboard. */ + fun createdBy(createdBy: CreatedBy?) = createdBy(JsonField.ofNullable(createdBy)) + + /** Alias for calling [Builder.createdBy] with `createdBy.orElse(null)`. */ + fun createdBy(createdBy: Optional) = createdBy(createdBy.getOrNull()) + + /** + * Sets [Builder.createdBy] to an arbitrary JSON value. + * + * You should usually call [Builder.createdBy] with a well-typed [CreatedBy] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdBy(createdBy: JsonField) = apply { this.createdBy = createdBy } + + /** + * If the validation is rejected by the card network or the destination financial + * institution, this will contain supplemental details. + */ + fun decline(decline: Decline?) = decline(JsonField.ofNullable(decline)) + + /** Alias for calling [Builder.decline] with `decline.orElse(null)`. */ + fun decline(decline: Optional) = decline(decline.getOrNull()) + + /** + * Sets [Builder.decline] to an arbitrary JSON value. + * + * You should usually call [Builder.decline] with a well-typed [Decline] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun decline(decline: JsonField) = apply { this.decline = decline } + + /** + * The idempotency key you chose for this object. This value is unique across Increase and + * is used to ensure that a request is only processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = + idempotencyKey(JsonField.ofNullable(idempotencyKey)) + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Sets [Builder.idempotencyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.idempotencyKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun idempotencyKey(idempotencyKey: JsonField) = apply { + this.idempotencyKey = idempotencyKey + } + + /** + * A four-digit code (MCC) identifying the type of business or service provided by the + * merchant. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] 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 + } + + /** The city where the merchant (typically your business) is located. */ + fun merchantCityName(merchantCityName: String) = + merchantCityName(JsonField.of(merchantCityName)) + + /** + * Sets [Builder.merchantCityName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCityName(merchantCityName: JsonField) = apply { + this.merchantCityName = merchantCityName + } + + /** + * The merchant name that will appear in the cardholder’s statement descriptor. Typically + * your business name. + */ + fun merchantName(merchantName: String) = merchantName(JsonField.of(merchantName)) + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantName(merchantName: JsonField) = apply { + this.merchantName = merchantName + } + + /** The postal code for the merchant’s (typically your business’s) location. */ + fun merchantPostalCode(merchantPostalCode: String) = + merchantPostalCode(JsonField.of(merchantPostalCode)) + + /** + * Sets [Builder.merchantPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantPostalCode(merchantPostalCode: JsonField) = apply { + this.merchantPostalCode = merchantPostalCode + } + + /** The U.S. state where the merchant (typically your business) is located. */ + fun merchantState(merchantState: String) = merchantState(JsonField.of(merchantState)) + + /** + * Sets [Builder.merchantState] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantState] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantState(merchantState: JsonField) = apply { + this.merchantState = merchantState + } + + /** The lifecycle status of the validation. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** + * After the validation is submitted to the card network, this will contain supplemental + * details. + */ + fun submission(submission: Submission?) = submission(JsonField.ofNullable(submission)) + + /** Alias for calling [Builder.submission] with `submission.orElse(null)`. */ + fun submission(submission: Optional) = submission(submission.getOrNull()) + + /** + * Sets [Builder.submission] to an arbitrary JSON value. + * + * You should usually call [Builder.submission] with a well-typed [Submission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun submission(submission: JsonField) = apply { this.submission = submission } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_validation`. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [CardValidation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .acceptance() + * .accountId() + * .cardholderFirstName() + * .cardholderLastName() + * .cardholderMiddleName() + * .cardholderPostalCode() + * .cardholderStreetAddress() + * .createdAt() + * .createdBy() + * .decline() + * .idempotencyKey() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantPostalCode() + * .merchantState() + * .status() + * .submission() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardValidation = + CardValidation( + checkRequired("id", id), + checkRequired("acceptance", acceptance), + checkRequired("accountId", accountId), + checkRequired("cardholderFirstName", cardholderFirstName), + checkRequired("cardholderLastName", cardholderLastName), + checkRequired("cardholderMiddleName", cardholderMiddleName), + checkRequired("cardholderPostalCode", cardholderPostalCode), + checkRequired("cardholderStreetAddress", cardholderStreetAddress), + checkRequired("createdAt", createdAt), + checkRequired("createdBy", createdBy), + checkRequired("decline", decline), + checkRequired("idempotencyKey", idempotencyKey), + checkRequired("merchantCategoryCode", merchantCategoryCode), + checkRequired("merchantCityName", merchantCityName), + checkRequired("merchantName", merchantName), + checkRequired("merchantPostalCode", merchantPostalCode), + checkRequired("merchantState", merchantState), + checkRequired("status", status), + checkRequired("submission", submission), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardValidation = apply { + if (validated) { + return@apply + } + + id() + acceptance().ifPresent { it.validate() } + accountId() + cardholderFirstName() + cardholderLastName() + cardholderMiddleName() + cardholderPostalCode() + cardholderStreetAddress() + createdAt() + createdBy().ifPresent { it.validate() } + decline().ifPresent { it.validate() } + idempotencyKey() + merchantCategoryCode() + merchantCityName() + merchantName() + merchantPostalCode() + merchantState() + status().validate() + submission().ifPresent { it.validate() } + type().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 = + (if (id.asKnown().isPresent) 1 else 0) + + (acceptance.asKnown().getOrNull()?.validity() ?: 0) + + (if (accountId.asKnown().isPresent) 1 else 0) + + (if (cardholderFirstName.asKnown().isPresent) 1 else 0) + + (if (cardholderLastName.asKnown().isPresent) 1 else 0) + + (if (cardholderMiddleName.asKnown().isPresent) 1 else 0) + + (if (cardholderPostalCode.asKnown().isPresent) 1 else 0) + + (if (cardholderStreetAddress.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (createdBy.asKnown().getOrNull()?.validity() ?: 0) + + (decline.asKnown().getOrNull()?.validity() ?: 0) + + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + (if (merchantCategoryCode.asKnown().isPresent) 1 else 0) + + (if (merchantCityName.asKnown().isPresent) 1 else 0) + + (if (merchantName.asKnown().isPresent) 1 else 0) + + (if (merchantPostalCode.asKnown().isPresent) 1 else 0) + + (if (merchantState.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (submission.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** + * If the validation is accepted by the recipient bank, this will contain supplemental details. + */ + class Acceptance + private constructor( + private val acceptedAt: JsonField, + private val authorizationIdentificationResponse: JsonField, + private val cardVerificationValue2Result: JsonField, + private val cardholderFirstNameResult: JsonField, + private val cardholderFullNameResult: JsonField, + private val cardholderLastNameResult: JsonField, + private val cardholderMiddleNameResult: JsonField, + private val cardholderPostalCodeResult: JsonField, + private val cardholderStreetAddressResult: JsonField, + private val networkTransactionIdentifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_at") + @ExcludeMissing + acceptedAt: JsonField = JsonMissing.of(), + @JsonProperty("authorization_identification_response") + @ExcludeMissing + authorizationIdentificationResponse: JsonField = JsonMissing.of(), + @JsonProperty("card_verification_value2_result") + @ExcludeMissing + cardVerificationValue2Result: JsonField = + JsonMissing.of(), + @JsonProperty("cardholder_first_name_result") + @ExcludeMissing + cardholderFirstNameResult: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_full_name_result") + @ExcludeMissing + cardholderFullNameResult: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_last_name_result") + @ExcludeMissing + cardholderLastNameResult: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_middle_name_result") + @ExcludeMissing + cardholderMiddleNameResult: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_postal_code_result") + @ExcludeMissing + cardholderPostalCodeResult: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_street_address_result") + @ExcludeMissing + cardholderStreetAddressResult: JsonField = + JsonMissing.of(), + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + networkTransactionIdentifier: JsonField = JsonMissing.of(), + ) : this( + acceptedAt, + authorizationIdentificationResponse, + cardVerificationValue2Result, + cardholderFirstNameResult, + cardholderFullNameResult, + cardholderLastNameResult, + cardholderMiddleNameResult, + cardholderPostalCodeResult, + cardholderStreetAddressResult, + networkTransactionIdentifier, + mutableMapOf(), + ) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was accepted by the issuing bank. + * + * @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 acceptedAt(): OffsetDateTime = acceptedAt.getRequired("accepted_at") + + /** + * The authorization identification response from the issuing bank. + * + * @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 authorizationIdentificationResponse(): String = + authorizationIdentificationResponse.getRequired("authorization_identification_response") + + /** + * The result of the Card Verification Value 2 match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardVerificationValue2Result(): Optional = + cardVerificationValue2Result.getOptional("card_verification_value2_result") + + /** + * The result of the cardholder first name match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderFirstNameResult(): Optional = + cardholderFirstNameResult.getOptional("cardholder_first_name_result") + + /** + * The result of the cardholder full name match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderFullNameResult(): Optional = + cardholderFullNameResult.getOptional("cardholder_full_name_result") + + /** + * The result of the cardholder last name match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderLastNameResult(): Optional = + cardholderLastNameResult.getOptional("cardholder_last_name_result") + + /** + * The result of the cardholder middle name match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderMiddleNameResult(): Optional = + cardholderMiddleNameResult.getOptional("cardholder_middle_name_result") + + /** + * The result of the cardholder postal code match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderPostalCodeResult(): Optional = + cardholderPostalCodeResult.getOptional("cardholder_postal_code_result") + + /** + * The result of the cardholder street address match. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderStreetAddressResult(): Optional = + cardholderStreetAddressResult.getOptional("cardholder_street_address_result") + + /** + * A unique identifier for the transaction on the card network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun networkTransactionIdentifier(): Optional = + networkTransactionIdentifier.getOptional("network_transaction_identifier") + + /** + * Returns the raw JSON value of [acceptedAt]. + * + * Unlike [acceptedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accepted_at") + @ExcludeMissing + fun _acceptedAt(): JsonField = acceptedAt + + /** + * Returns the raw JSON value of [authorizationIdentificationResponse]. + * + * Unlike [authorizationIdentificationResponse], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("authorization_identification_response") + @ExcludeMissing + fun _authorizationIdentificationResponse(): JsonField = + authorizationIdentificationResponse + + /** + * Returns the raw JSON value of [cardVerificationValue2Result]. + * + * Unlike [cardVerificationValue2Result], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("card_verification_value2_result") + @ExcludeMissing + fun _cardVerificationValue2Result(): JsonField = + cardVerificationValue2Result + + /** + * Returns the raw JSON value of [cardholderFirstNameResult]. + * + * Unlike [cardholderFirstNameResult], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_first_name_result") + @ExcludeMissing + fun _cardholderFirstNameResult(): JsonField = + cardholderFirstNameResult + + /** + * Returns the raw JSON value of [cardholderFullNameResult]. + * + * Unlike [cardholderFullNameResult], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_full_name_result") + @ExcludeMissing + fun _cardholderFullNameResult(): JsonField = + cardholderFullNameResult + + /** + * Returns the raw JSON value of [cardholderLastNameResult]. + * + * Unlike [cardholderLastNameResult], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_last_name_result") + @ExcludeMissing + fun _cardholderLastNameResult(): JsonField = + cardholderLastNameResult + + /** + * Returns the raw JSON value of [cardholderMiddleNameResult]. + * + * Unlike [cardholderMiddleNameResult], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_middle_name_result") + @ExcludeMissing + fun _cardholderMiddleNameResult(): JsonField = + cardholderMiddleNameResult + + /** + * Returns the raw JSON value of [cardholderPostalCodeResult]. + * + * Unlike [cardholderPostalCodeResult], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_postal_code_result") + @ExcludeMissing + fun _cardholderPostalCodeResult(): JsonField = + cardholderPostalCodeResult + + /** + * Returns the raw JSON value of [cardholderStreetAddressResult]. + * + * Unlike [cardholderStreetAddressResult], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cardholder_street_address_result") + @ExcludeMissing + fun _cardholderStreetAddressResult(): JsonField = + cardholderStreetAddressResult + + /** + * Returns the raw JSON value of [networkTransactionIdentifier]. + * + * Unlike [networkTransactionIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + fun _networkTransactionIdentifier(): JsonField = networkTransactionIdentifier + + @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 [Acceptance]. + * + * The following fields are required: + * ```java + * .acceptedAt() + * .authorizationIdentificationResponse() + * .cardVerificationValue2Result() + * .cardholderFirstNameResult() + * .cardholderFullNameResult() + * .cardholderLastNameResult() + * .cardholderMiddleNameResult() + * .cardholderPostalCodeResult() + * .cardholderStreetAddressResult() + * .networkTransactionIdentifier() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Acceptance]. */ + class Builder internal constructor() { + + private var acceptedAt: JsonField? = null + private var authorizationIdentificationResponse: JsonField? = null + private var cardVerificationValue2Result: JsonField? = + null + private var cardholderFirstNameResult: JsonField? = null + private var cardholderFullNameResult: JsonField? = null + private var cardholderLastNameResult: JsonField? = null + private var cardholderMiddleNameResult: JsonField? = null + private var cardholderPostalCodeResult: JsonField? = null + private var cardholderStreetAddressResult: JsonField? = + null + private var networkTransactionIdentifier: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(acceptance: Acceptance) = apply { + acceptedAt = acceptance.acceptedAt + authorizationIdentificationResponse = acceptance.authorizationIdentificationResponse + cardVerificationValue2Result = acceptance.cardVerificationValue2Result + cardholderFirstNameResult = acceptance.cardholderFirstNameResult + cardholderFullNameResult = acceptance.cardholderFullNameResult + cardholderLastNameResult = acceptance.cardholderLastNameResult + cardholderMiddleNameResult = acceptance.cardholderMiddleNameResult + cardholderPostalCodeResult = acceptance.cardholderPostalCodeResult + cardholderStreetAddressResult = acceptance.cardholderStreetAddressResult + networkTransactionIdentifier = acceptance.networkTransactionIdentifier + additionalProperties = acceptance.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was accepted by the issuing bank. + */ + fun acceptedAt(acceptedAt: OffsetDateTime) = acceptedAt(JsonField.of(acceptedAt)) + + /** + * Sets [Builder.acceptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptedAt(acceptedAt: JsonField) = apply { + this.acceptedAt = acceptedAt + } + + /** The authorization identification response from the issuing bank. */ + fun authorizationIdentificationResponse(authorizationIdentificationResponse: String) = + authorizationIdentificationResponse( + JsonField.of(authorizationIdentificationResponse) + ) + + /** + * Sets [Builder.authorizationIdentificationResponse] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationIdentificationResponse] with a + * well-typed [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authorizationIdentificationResponse( + authorizationIdentificationResponse: JsonField + ) = apply { + this.authorizationIdentificationResponse = authorizationIdentificationResponse + } + + /** The result of the Card Verification Value 2 match. */ + fun cardVerificationValue2Result( + cardVerificationValue2Result: CardVerificationValue2Result? + ) = cardVerificationValue2Result(JsonField.ofNullable(cardVerificationValue2Result)) + + /** + * Alias for calling [Builder.cardVerificationValue2Result] with + * `cardVerificationValue2Result.orElse(null)`. + */ + fun cardVerificationValue2Result( + cardVerificationValue2Result: Optional + ) = cardVerificationValue2Result(cardVerificationValue2Result.getOrNull()) + + /** + * Sets [Builder.cardVerificationValue2Result] to an arbitrary JSON value. + * + * You should usually call [Builder.cardVerificationValue2Result] with a well-typed + * [CardVerificationValue2Result] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardVerificationValue2Result( + cardVerificationValue2Result: JsonField + ) = apply { this.cardVerificationValue2Result = cardVerificationValue2Result } + + /** The result of the cardholder first name match. */ + fun cardholderFirstNameResult(cardholderFirstNameResult: CardholderFirstNameResult?) = + cardholderFirstNameResult(JsonField.ofNullable(cardholderFirstNameResult)) + + /** + * Alias for calling [Builder.cardholderFirstNameResult] with + * `cardholderFirstNameResult.orElse(null)`. + */ + fun cardholderFirstNameResult( + cardholderFirstNameResult: Optional + ) = cardholderFirstNameResult(cardholderFirstNameResult.getOrNull()) + + /** + * Sets [Builder.cardholderFirstNameResult] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderFirstNameResult] with a well-typed + * [CardholderFirstNameResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderFirstNameResult( + cardholderFirstNameResult: JsonField + ) = apply { this.cardholderFirstNameResult = cardholderFirstNameResult } + + /** The result of the cardholder full name match. */ + fun cardholderFullNameResult(cardholderFullNameResult: CardholderFullNameResult?) = + cardholderFullNameResult(JsonField.ofNullable(cardholderFullNameResult)) + + /** + * Alias for calling [Builder.cardholderFullNameResult] with + * `cardholderFullNameResult.orElse(null)`. + */ + fun cardholderFullNameResult( + cardholderFullNameResult: Optional + ) = cardholderFullNameResult(cardholderFullNameResult.getOrNull()) + + /** + * Sets [Builder.cardholderFullNameResult] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderFullNameResult] with a well-typed + * [CardholderFullNameResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderFullNameResult( + cardholderFullNameResult: JsonField + ) = apply { this.cardholderFullNameResult = cardholderFullNameResult } + + /** The result of the cardholder last name match. */ + fun cardholderLastNameResult(cardholderLastNameResult: CardholderLastNameResult?) = + cardholderLastNameResult(JsonField.ofNullable(cardholderLastNameResult)) + + /** + * Alias for calling [Builder.cardholderLastNameResult] with + * `cardholderLastNameResult.orElse(null)`. + */ + fun cardholderLastNameResult( + cardholderLastNameResult: Optional + ) = cardholderLastNameResult(cardholderLastNameResult.getOrNull()) + + /** + * Sets [Builder.cardholderLastNameResult] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderLastNameResult] with a well-typed + * [CardholderLastNameResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderLastNameResult( + cardholderLastNameResult: JsonField + ) = apply { this.cardholderLastNameResult = cardholderLastNameResult } + + /** The result of the cardholder middle name match. */ + fun cardholderMiddleNameResult( + cardholderMiddleNameResult: CardholderMiddleNameResult? + ) = cardholderMiddleNameResult(JsonField.ofNullable(cardholderMiddleNameResult)) + + /** + * Alias for calling [Builder.cardholderMiddleNameResult] with + * `cardholderMiddleNameResult.orElse(null)`. + */ + fun cardholderMiddleNameResult( + cardholderMiddleNameResult: Optional + ) = cardholderMiddleNameResult(cardholderMiddleNameResult.getOrNull()) + + /** + * Sets [Builder.cardholderMiddleNameResult] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderMiddleNameResult] with a well-typed + * [CardholderMiddleNameResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderMiddleNameResult( + cardholderMiddleNameResult: JsonField + ) = apply { this.cardholderMiddleNameResult = cardholderMiddleNameResult } + + /** The result of the cardholder postal code match. */ + fun cardholderPostalCodeResult( + cardholderPostalCodeResult: CardholderPostalCodeResult? + ) = cardholderPostalCodeResult(JsonField.ofNullable(cardholderPostalCodeResult)) + + /** + * Alias for calling [Builder.cardholderPostalCodeResult] with + * `cardholderPostalCodeResult.orElse(null)`. + */ + fun cardholderPostalCodeResult( + cardholderPostalCodeResult: Optional + ) = cardholderPostalCodeResult(cardholderPostalCodeResult.getOrNull()) + + /** + * Sets [Builder.cardholderPostalCodeResult] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPostalCodeResult] with a well-typed + * [CardholderPostalCodeResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderPostalCodeResult( + cardholderPostalCodeResult: JsonField + ) = apply { this.cardholderPostalCodeResult = cardholderPostalCodeResult } + + /** The result of the cardholder street address match. */ + fun cardholderStreetAddressResult( + cardholderStreetAddressResult: CardholderStreetAddressResult? + ) = cardholderStreetAddressResult(JsonField.ofNullable(cardholderStreetAddressResult)) + + /** + * Alias for calling [Builder.cardholderStreetAddressResult] with + * `cardholderStreetAddressResult.orElse(null)`. + */ + fun cardholderStreetAddressResult( + cardholderStreetAddressResult: Optional + ) = cardholderStreetAddressResult(cardholderStreetAddressResult.getOrNull()) + + /** + * Sets [Builder.cardholderStreetAddressResult] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderStreetAddressResult] with a well-typed + * [CardholderStreetAddressResult] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardholderStreetAddressResult( + cardholderStreetAddressResult: JsonField + ) = apply { this.cardholderStreetAddressResult = cardholderStreetAddressResult } + + /** A unique identifier for the transaction on the card network. */ + fun networkTransactionIdentifier(networkTransactionIdentifier: String?) = + networkTransactionIdentifier(JsonField.ofNullable(networkTransactionIdentifier)) + + /** + * Alias for calling [Builder.networkTransactionIdentifier] with + * `networkTransactionIdentifier.orElse(null)`. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: Optional) = + networkTransactionIdentifier(networkTransactionIdentifier.getOrNull()) + + /** + * Sets [Builder.networkTransactionIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.networkTransactionIdentifier] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: JsonField) = + apply { + this.networkTransactionIdentifier = networkTransactionIdentifier + } + + 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 [Acceptance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedAt() + * .authorizationIdentificationResponse() + * .cardVerificationValue2Result() + * .cardholderFirstNameResult() + * .cardholderFullNameResult() + * .cardholderLastNameResult() + * .cardholderMiddleNameResult() + * .cardholderPostalCodeResult() + * .cardholderStreetAddressResult() + * .networkTransactionIdentifier() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Acceptance = + Acceptance( + checkRequired("acceptedAt", acceptedAt), + checkRequired( + "authorizationIdentificationResponse", + authorizationIdentificationResponse, + ), + checkRequired("cardVerificationValue2Result", cardVerificationValue2Result), + checkRequired("cardholderFirstNameResult", cardholderFirstNameResult), + checkRequired("cardholderFullNameResult", cardholderFullNameResult), + checkRequired("cardholderLastNameResult", cardholderLastNameResult), + checkRequired("cardholderMiddleNameResult", cardholderMiddleNameResult), + checkRequired("cardholderPostalCodeResult", cardholderPostalCodeResult), + checkRequired("cardholderStreetAddressResult", cardholderStreetAddressResult), + checkRequired("networkTransactionIdentifier", networkTransactionIdentifier), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Acceptance = apply { + if (validated) { + return@apply + } + + acceptedAt() + authorizationIdentificationResponse() + cardVerificationValue2Result().ifPresent { it.validate() } + cardholderFirstNameResult().ifPresent { it.validate() } + cardholderFullNameResult().ifPresent { it.validate() } + cardholderLastNameResult().ifPresent { it.validate() } + cardholderMiddleNameResult().ifPresent { it.validate() } + cardholderPostalCodeResult().ifPresent { it.validate() } + cardholderStreetAddressResult().ifPresent { it.validate() } + networkTransactionIdentifier() + 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 (acceptedAt.asKnown().isPresent) 1 else 0) + + (if (authorizationIdentificationResponse.asKnown().isPresent) 1 else 0) + + (cardVerificationValue2Result.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderFirstNameResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderFullNameResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderLastNameResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderMiddleNameResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderPostalCodeResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderStreetAddressResult.asKnown().getOrNull()?.validity() ?: 0) + + (if (networkTransactionIdentifier.asKnown().isPresent) 1 else 0) + + /** The result of the Card Verification Value 2 match. */ + class CardVerificationValue2Result + @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 Card Verification Value 2 (CVV2) matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The Card Verification Value 2 (CVV2) does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + @JvmStatic fun of(value: String) = CardVerificationValue2Result(JsonField.of(value)) + } + + /** An enum containing [CardVerificationValue2Result]'s known values. */ + enum class Known { + /** The Card Verification Value 2 (CVV2) matches the expected value. */ + MATCH, + /** The Card Verification Value 2 (CVV2) does not match the expected value. */ + NO_MATCH, + } + + /** + * An enum containing [CardVerificationValue2Result]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardVerificationValue2Result] 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 Card Verification Value 2 (CVV2) matches the expected value. */ + MATCH, + /** The Card Verification Value 2 (CVV2) does not match the expected value. */ + NO_MATCH, + /** + * An enum member indicating that [CardVerificationValue2Result] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardVerificationValue2Result: $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(): CardVerificationValue2Result = 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 CardVerificationValue2Result && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The result of the cardholder first name match. */ + class CardholderFirstNameResult + @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 cardholder name component matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The cardholder name component does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + /** The cardholder name component partially matches the expected value. */ + @JvmField val PARTIAL_MATCH = of("partial_match") + + @JvmStatic fun of(value: String) = CardholderFirstNameResult(JsonField.of(value)) + } + + /** An enum containing [CardholderFirstNameResult]'s known values. */ + enum class Known { + /** The cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + } + + /** + * An enum containing [CardholderFirstNameResult]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderFirstNameResult] 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 cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + /** + * An enum member indicating that [CardholderFirstNameResult] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + PARTIAL_MATCH -> Value.PARTIAL_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + PARTIAL_MATCH -> Known.PARTIAL_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderFirstNameResult: $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(): CardholderFirstNameResult = 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 CardholderFirstNameResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The result of the cardholder full name match. */ + class CardholderFullNameResult + @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 cardholder name component matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The cardholder name component does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + /** The cardholder name component partially matches the expected value. */ + @JvmField val PARTIAL_MATCH = of("partial_match") + + @JvmStatic fun of(value: String) = CardholderFullNameResult(JsonField.of(value)) + } + + /** An enum containing [CardholderFullNameResult]'s known values. */ + enum class Known { + /** The cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + } + + /** + * An enum containing [CardholderFullNameResult]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderFullNameResult] 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 cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + /** + * An enum member indicating that [CardholderFullNameResult] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + PARTIAL_MATCH -> Value.PARTIAL_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + PARTIAL_MATCH -> Known.PARTIAL_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderFullNameResult: $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(): CardholderFullNameResult = 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 CardholderFullNameResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The result of the cardholder last name match. */ + class CardholderLastNameResult + @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 cardholder name component matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The cardholder name component does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + /** The cardholder name component partially matches the expected value. */ + @JvmField val PARTIAL_MATCH = of("partial_match") + + @JvmStatic fun of(value: String) = CardholderLastNameResult(JsonField.of(value)) + } + + /** An enum containing [CardholderLastNameResult]'s known values. */ + enum class Known { + /** The cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + } + + /** + * An enum containing [CardholderLastNameResult]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderLastNameResult] 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 cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + /** + * An enum member indicating that [CardholderLastNameResult] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + PARTIAL_MATCH -> Value.PARTIAL_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + PARTIAL_MATCH -> Known.PARTIAL_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderLastNameResult: $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(): CardholderLastNameResult = 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 CardholderLastNameResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The result of the cardholder middle name match. */ + class CardholderMiddleNameResult + @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 cardholder name component matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The cardholder name component does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + /** The cardholder name component partially matches the expected value. */ + @JvmField val PARTIAL_MATCH = of("partial_match") + + @JvmStatic fun of(value: String) = CardholderMiddleNameResult(JsonField.of(value)) + } + + /** An enum containing [CardholderMiddleNameResult]'s known values. */ + enum class Known { + /** The cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + } + + /** + * An enum containing [CardholderMiddleNameResult]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderMiddleNameResult] 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 cardholder name component matches the expected value. */ + MATCH, + /** The cardholder name component does not match the expected value. */ + NO_MATCH, + /** The cardholder name component partially matches the expected value. */ + PARTIAL_MATCH, + /** + * An enum member indicating that [CardholderMiddleNameResult] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + PARTIAL_MATCH -> Value.PARTIAL_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + PARTIAL_MATCH -> Known.PARTIAL_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderMiddleNameResult: $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(): CardholderMiddleNameResult = 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 CardholderMiddleNameResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The result of the cardholder postal code match. */ + class CardholderPostalCodeResult + @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 cardholder address component matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The cardholder address component does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + @JvmStatic fun of(value: String) = CardholderPostalCodeResult(JsonField.of(value)) + } + + /** An enum containing [CardholderPostalCodeResult]'s known values. */ + enum class Known { + /** The cardholder address component matches the expected value. */ + MATCH, + /** The cardholder address component does not match the expected value. */ + NO_MATCH, + } + + /** + * An enum containing [CardholderPostalCodeResult]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderPostalCodeResult] 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 cardholder address component matches the expected value. */ + MATCH, + /** The cardholder address component does not match the expected value. */ + NO_MATCH, + /** + * An enum member indicating that [CardholderPostalCodeResult] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderPostalCodeResult: $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(): CardholderPostalCodeResult = 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 CardholderPostalCodeResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The result of the cardholder street address match. */ + class CardholderStreetAddressResult + @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 cardholder address component matches the expected value. */ + @JvmField val MATCH = of("match") + + /** The cardholder address component does not match the expected value. */ + @JvmField val NO_MATCH = of("no_match") + + @JvmStatic + fun of(value: String) = CardholderStreetAddressResult(JsonField.of(value)) + } + + /** An enum containing [CardholderStreetAddressResult]'s known values. */ + enum class Known { + /** The cardholder address component matches the expected value. */ + MATCH, + /** The cardholder address component does not match the expected value. */ + NO_MATCH, + } + + /** + * An enum containing [CardholderStreetAddressResult]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderStreetAddressResult] 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 cardholder address component matches the expected value. */ + MATCH, + /** The cardholder address component does not match the expected value. */ + NO_MATCH, + /** + * An enum member indicating that [CardholderStreetAddressResult] 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) { + MATCH -> Value.MATCH + NO_MATCH -> Value.NO_MATCH + 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) { + MATCH -> Known.MATCH + NO_MATCH -> Known.NO_MATCH + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderStreetAddressResult: $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(): CardholderStreetAddressResult = 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 CardholderStreetAddressResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Acceptance && + acceptedAt == other.acceptedAt && + authorizationIdentificationResponse == other.authorizationIdentificationResponse && + cardVerificationValue2Result == other.cardVerificationValue2Result && + cardholderFirstNameResult == other.cardholderFirstNameResult && + cardholderFullNameResult == other.cardholderFullNameResult && + cardholderLastNameResult == other.cardholderLastNameResult && + cardholderMiddleNameResult == other.cardholderMiddleNameResult && + cardholderPostalCodeResult == other.cardholderPostalCodeResult && + cardholderStreetAddressResult == other.cardholderStreetAddressResult && + networkTransactionIdentifier == other.networkTransactionIdentifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptedAt, + authorizationIdentificationResponse, + cardVerificationValue2Result, + cardholderFirstNameResult, + cardholderFullNameResult, + cardholderLastNameResult, + cardholderMiddleNameResult, + cardholderPostalCodeResult, + cardholderStreetAddressResult, + networkTransactionIdentifier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Acceptance{acceptedAt=$acceptedAt, authorizationIdentificationResponse=$authorizationIdentificationResponse, cardVerificationValue2Result=$cardVerificationValue2Result, cardholderFirstNameResult=$cardholderFirstNameResult, cardholderFullNameResult=$cardholderFullNameResult, cardholderLastNameResult=$cardholderLastNameResult, cardholderMiddleNameResult=$cardholderMiddleNameResult, cardholderPostalCodeResult=$cardholderPostalCodeResult, cardholderStreetAddressResult=$cardholderStreetAddressResult, networkTransactionIdentifier=$networkTransactionIdentifier, additionalProperties=$additionalProperties}" + } + + /** What object created the validation, either via the API or the dashboard. */ + class CreatedBy + private constructor( + private val apiKey: JsonField, + private val category: JsonField, + private val oauthApplication: JsonField, + private val user: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("api_key") @ExcludeMissing apiKey: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("oauth_application") + @ExcludeMissing + oauthApplication: JsonField = JsonMissing.of(), + @JsonProperty("user") @ExcludeMissing user: JsonField = JsonMissing.of(), + ) : this(apiKey, category, oauthApplication, user, mutableMapOf()) + + /** + * If present, details about the API key that created the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun apiKey(): Optional = apiKey.getOptional("api_key") + + /** + * The type of object that created this transfer. + * + * @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 category(): Category = category.getRequired("category") + + /** + * If present, details about the OAuth Application that created the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun oauthApplication(): Optional = + oauthApplication.getOptional("oauth_application") + + /** + * If present, details about the User that created the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun user(): Optional = user.getOptional("user") + + /** + * Returns the raw JSON value of [apiKey]. + * + * Unlike [apiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("api_key") @ExcludeMissing fun _apiKey(): JsonField = apiKey + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [oauthApplication]. + * + * Unlike [oauthApplication], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("oauth_application") + @ExcludeMissing + fun _oauthApplication(): JsonField = oauthApplication + + /** + * Returns the raw JSON value of [user]. + * + * Unlike [user], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user") @ExcludeMissing fun _user(): JsonField = user + + @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 [CreatedBy]. + * + * The following fields are required: + * ```java + * .apiKey() + * .category() + * .oauthApplication() + * .user() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedBy]. */ + class Builder internal constructor() { + + private var apiKey: JsonField? = null + private var category: JsonField? = null + private var oauthApplication: JsonField? = null + private var user: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createdBy: CreatedBy) = apply { + apiKey = createdBy.apiKey + category = createdBy.category + oauthApplication = createdBy.oauthApplication + user = createdBy.user + additionalProperties = createdBy.additionalProperties.toMutableMap() + } + + /** If present, details about the API key that created the transfer. */ + fun apiKey(apiKey: ApiKey?) = apiKey(JsonField.ofNullable(apiKey)) + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + + /** + * Sets [Builder.apiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.apiKey] with a well-typed [ApiKey] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun apiKey(apiKey: JsonField) = apply { this.apiKey = apiKey } + + /** The type of object that created this transfer. */ + fun category(category: Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [Category] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun category(category: JsonField) = apply { this.category = category } + + /** If present, details about the OAuth Application that created the transfer. */ + fun oauthApplication(oauthApplication: OAuthApplication?) = + oauthApplication(JsonField.ofNullable(oauthApplication)) + + /** + * Alias for calling [Builder.oauthApplication] with `oauthApplication.orElse(null)`. + */ + fun oauthApplication(oauthApplication: Optional) = + oauthApplication(oauthApplication.getOrNull()) + + /** + * Sets [Builder.oauthApplication] to an arbitrary JSON value. + * + * You should usually call [Builder.oauthApplication] with a well-typed + * [OAuthApplication] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun oauthApplication(oauthApplication: JsonField) = apply { + this.oauthApplication = oauthApplication + } + + /** If present, details about the User that created the transfer. */ + fun user(user: User?) = user(JsonField.ofNullable(user)) + + /** Alias for calling [Builder.user] with `user.orElse(null)`. */ + fun user(user: Optional) = user(user.getOrNull()) + + /** + * Sets [Builder.user] to an arbitrary JSON value. + * + * You should usually call [Builder.user] with a well-typed [User] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun user(user: JsonField) = apply { this.user = user } + + 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 [CreatedBy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKey() + * .category() + * .oauthApplication() + * .user() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreatedBy = + CreatedBy( + checkRequired("apiKey", apiKey), + checkRequired("category", category), + checkRequired("oauthApplication", oauthApplication), + checkRequired("user", user), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreatedBy = apply { + if (validated) { + return@apply + } + + apiKey().ifPresent { it.validate() } + category().validate() + oauthApplication().ifPresent { it.validate() } + user().ifPresent { 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 = + (apiKey.asKnown().getOrNull()?.validity() ?: 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (oauthApplication.asKnown().getOrNull()?.validity() ?: 0) + + (user.asKnown().getOrNull()?.validity() ?: 0) + + /** If present, details about the API key that created the transfer. */ + class ApiKey + private constructor( + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of() + ) : this(description, mutableMapOf()) + + /** + * The description set for the API key when it was created. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @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 [ApiKey]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKey]. */ + class Builder internal constructor() { + + private var description: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKey: ApiKey) = apply { + description = apiKey.description + additionalProperties = apiKey.additionalProperties.toMutableMap() + } + + /** The description set for the API key when it was created. */ + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + 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 [ApiKey]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApiKey = + ApiKey( + checkRequired("description", description), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ApiKey = apply { + if (validated) { + return@apply + } + + description() + 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 (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKey && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(description, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiKey{description=$description, additionalProperties=$additionalProperties}" + } + + /** The type of object that created this transfer. */ + class Category @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 { + + /** An API key. Details will be under the `api_key` object. */ + @JvmField val API_KEY = of("api_key") + + /** + * An OAuth application you connected to Increase. Details will be under the + * `oauth_application` object. + */ + @JvmField val OAUTH_APPLICATION = of("oauth_application") + + /** A User in the Increase dashboard. Details will be under the `user` object. */ + @JvmField val USER = of("user") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** An API key. Details will be under the `api_key` object. */ + API_KEY, + /** + * An OAuth application you connected to Increase. Details will be under the + * `oauth_application` object. + */ + OAUTH_APPLICATION, + /** A User in the Increase dashboard. Details will be under the `user` object. */ + USER, + } + + /** + * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Category] 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 { + /** An API key. Details will be under the `api_key` object. */ + API_KEY, + /** + * An OAuth application you connected to Increase. Details will be under the + * `oauth_application` object. + */ + OAUTH_APPLICATION, + /** A User in the Increase dashboard. Details will be under the `user` object. */ + USER, + /** + * An enum member indicating that [Category] 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) { + API_KEY -> Value.API_KEY + OAUTH_APPLICATION -> Value.OAUTH_APPLICATION + USER -> Value.USER + 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) { + API_KEY -> Known.API_KEY + OAUTH_APPLICATION -> Known.OAUTH_APPLICATION + USER -> Known.USER + else -> throw IncreaseInvalidDataException("Unknown Category: $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(): Category = 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 Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** If present, details about the OAuth Application that created the transfer. */ + class OAuthApplication + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * The name of the OAuth Application. + * + * @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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OAuthApplication]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OAuthApplication]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(oauthApplication: OAuthApplication) = apply { + name = oauthApplication.name + additionalProperties = oauthApplication.additionalProperties.toMutableMap() + } + + /** The name of the OAuth Application. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OAuthApplication]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OAuthApplication = + OAuthApplication( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OAuthApplication = apply { + if (validated) { + return@apply + } + + name() + 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 (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OAuthApplication && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OAuthApplication{name=$name, additionalProperties=$additionalProperties}" + } + + /** If present, details about the User that created the transfer. */ + class User + private constructor( + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of() + ) : this(email, mutableMapOf()) + + /** + * The email address of the User. + * + * @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 email(): String = email.getRequired("email") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @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 [User]. + * + * The following fields are required: + * ```java + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [User]. */ + class Builder internal constructor() { + + private var email: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(user: User) = apply { + email = user.email + additionalProperties = user.additionalProperties.toMutableMap() + } + + /** The email address of the User. */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + 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 [User]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): User = + User(checkRequired("email", email), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): User = apply { + if (validated) { + return@apply + } + + email() + 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 (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is User && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(email, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "User{email=$email, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedBy && + apiKey == other.apiKey && + category == other.category && + oauthApplication == other.oauthApplication && + user == other.user && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(apiKey, category, oauthApplication, user, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedBy{apiKey=$apiKey, category=$category, oauthApplication=$oauthApplication, user=$user, additionalProperties=$additionalProperties}" + } + + /** + * If the validation is rejected by the card network or the destination financial institution, + * this will contain supplemental details. + */ + class Decline + private constructor( + private val declinedAt: JsonField, + private val networkTransactionIdentifier: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("declined_at") + @ExcludeMissing + declinedAt: JsonField = JsonMissing.of(), + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + networkTransactionIdentifier: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + ) : this(declinedAt, networkTransactionIdentifier, reason, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was declined. + * + * @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 declinedAt(): OffsetDateTime = declinedAt.getRequired("declined_at") + + /** + * A unique identifier for the transaction on the card network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun networkTransactionIdentifier(): Optional = + networkTransactionIdentifier.getOptional("network_transaction_identifier") + + /** + * The reason why the validation was declined. + * + * @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 reason(): Reason = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [declinedAt]. + * + * Unlike [declinedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("declined_at") + @ExcludeMissing + fun _declinedAt(): JsonField = declinedAt + + /** + * Returns the raw JSON value of [networkTransactionIdentifier]. + * + * Unlike [networkTransactionIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("network_transaction_identifier") + @ExcludeMissing + fun _networkTransactionIdentifier(): JsonField = networkTransactionIdentifier + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @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 [Decline]. + * + * The following fields are required: + * ```java + * .declinedAt() + * .networkTransactionIdentifier() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Decline]. */ + class Builder internal constructor() { + + private var declinedAt: JsonField? = null + private var networkTransactionIdentifier: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(decline: Decline) = apply { + declinedAt = decline.declinedAt + networkTransactionIdentifier = decline.networkTransactionIdentifier + reason = decline.reason + additionalProperties = decline.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was declined. + */ + fun declinedAt(declinedAt: OffsetDateTime) = declinedAt(JsonField.of(declinedAt)) + + /** + * Sets [Builder.declinedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.declinedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun declinedAt(declinedAt: JsonField) = apply { + this.declinedAt = declinedAt + } + + /** A unique identifier for the transaction on the card network. */ + fun networkTransactionIdentifier(networkTransactionIdentifier: String?) = + networkTransactionIdentifier(JsonField.ofNullable(networkTransactionIdentifier)) + + /** + * Alias for calling [Builder.networkTransactionIdentifier] with + * `networkTransactionIdentifier.orElse(null)`. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: Optional) = + networkTransactionIdentifier(networkTransactionIdentifier.getOrNull()) + + /** + * Sets [Builder.networkTransactionIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.networkTransactionIdentifier] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun networkTransactionIdentifier(networkTransactionIdentifier: JsonField) = + apply { + this.networkTransactionIdentifier = networkTransactionIdentifier + } + + /** The reason why the validation was declined. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Reason] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + 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 [Decline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .declinedAt() + * .networkTransactionIdentifier() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Decline = + Decline( + checkRequired("declinedAt", declinedAt), + checkRequired("networkTransactionIdentifier", networkTransactionIdentifier), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Decline = apply { + if (validated) { + return@apply + } + + declinedAt() + networkTransactionIdentifier() + reason().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 = + (if (declinedAt.asKnown().isPresent) 1 else 0) + + (if (networkTransactionIdentifier.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** The reason why the validation was declined. */ + class Reason @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 card issuer has declined the transaction without providing a specific reason. + */ + @JvmField val DO_NOT_HONOR = of("do_not_honor") + + /** + * The number of transactions for the card has exceeded the limit set by the issuer. + */ + @JvmField val ACTIVITY_COUNT_LIMIT_EXCEEDED = of("activity_count_limit_exceeded") + + /** + * The card issuer requires the cardholder to contact them for further information + * regarding the transaction. + */ + @JvmField val REFER_TO_CARD_ISSUER = of("refer_to_card_issuer") + + /** + * The card issuer requires the cardholder to contact them due to a special + * condition related to the transaction. + */ + @JvmField + val REFER_TO_CARD_ISSUER_SPECIAL_CONDITION = + of("refer_to_card_issuer_special_condition") + + /** The merchant is not valid for this transaction. */ + @JvmField val INVALID_MERCHANT = of("invalid_merchant") + + /** The card should be retained by the terminal. */ + @JvmField val PICK_UP_CARD = of("pick_up_card") + + /** An error occurred during processing of the transaction. */ + @JvmField val ERROR = of("error") + + /** The card should be retained by the terminal due to a special condition. */ + @JvmField val PICK_UP_CARD_SPECIAL = of("pick_up_card_special") + + /** The transaction is invalid and cannot be processed. */ + @JvmField val INVALID_TRANSACTION = of("invalid_transaction") + + /** The amount of the transaction is invalid. */ + @JvmField val INVALID_AMOUNT = of("invalid_amount") + + /** The account number provided is invalid. */ + @JvmField val INVALID_ACCOUNT_NUMBER = of("invalid_account_number") + + /** The issuer of the card could not be found. */ + @JvmField val NO_SUCH_ISSUER = of("no_such_issuer") + + /** The transaction should be re-entered for processing. */ + @JvmField val RE_ENTER_TRANSACTION = of("re_enter_transaction") + + /** There is no credit account associated with the card. */ + @JvmField val NO_CREDIT_ACCOUNT = of("no_credit_account") + + /** + * The card should be retained by the terminal because it has been reported lost. + */ + @JvmField val PICK_UP_CARD_LOST = of("pick_up_card_lost") + + /** + * The card should be retained by the terminal because it has been reported stolen. + */ + @JvmField val PICK_UP_CARD_STOLEN = of("pick_up_card_stolen") + + /** The account associated with the card has been closed. */ + @JvmField val CLOSED_ACCOUNT = of("closed_account") + + /** There are insufficient funds in the account to complete the transaction. */ + @JvmField val INSUFFICIENT_FUNDS = of("insufficient_funds") + + /** There is no checking account associated with the card. */ + @JvmField val NO_CHECKING_ACCOUNT = of("no_checking_account") + + /** There is no savings account associated with the card. */ + @JvmField val NO_SAVINGS_ACCOUNT = of("no_savings_account") + + /** The card has expired and cannot be used for transactions. */ + @JvmField val EXPIRED_CARD = of("expired_card") + + /** The transaction is not permitted for this cardholder. */ + @JvmField + val TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER = + of("transaction_not_permitted_to_cardholder") + + /** The transaction is not allowed at this terminal. */ + @JvmField + val TRANSACTION_NOT_ALLOWED_AT_TERMINAL = of("transaction_not_allowed_at_terminal") + + /** The transaction has been flagged as suspected fraud and cannot be processed. */ + @JvmField val SUSPECTED_FRAUD = of("suspected_fraud") + + /** The amount of activity on the card has exceeded the limit set by the issuer. */ + @JvmField val ACTIVITY_AMOUNT_LIMIT_EXCEEDED = of("activity_amount_limit_exceeded") + + /** + * The card has restrictions that prevent it from being used for this transaction. + */ + @JvmField val RESTRICTED_CARD = of("restricted_card") + + /** + * A security violation has occurred, preventing the transaction from being + * processed. + */ + @JvmField val SECURITY_VIOLATION = of("security_violation") + + /** + * The transaction does not meet the anti-money laundering requirements set by the + * issuer. + */ + @JvmField + val TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT = + of("transaction_does_not_fulfill_anti_money_laundering_requirement") + + /** The first use of the card has been blocked by the issuer. */ + @JvmField val BLOCKED_FIRST_USE = of("blocked_first_use") + + /** The credit issuer is currently unavailable to process the transaction. */ + @JvmField val CREDIT_ISSUER_UNAVAILABLE = of("credit_issuer_unavailable") + + /** + * The card verification value (CVV) results were negative, indicating a potential + * issue with the card. + */ + @JvmField + val NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS = + of("negative_card_verification_value_results") + + /** The issuer of the card is currently unavailable to process the transaction. */ + @JvmField val ISSUER_UNAVAILABLE = of("issuer_unavailable") + + /** The financial institution associated with the card could not be found. */ + @JvmField + val FINANCIAL_INSTITUTION_CANNOT_BE_FOUND = + of("financial_institution_cannot_be_found") + + /** The transaction cannot be completed due to an unspecified reason. */ + @JvmField + val TRANSACTION_CANNOT_BE_COMPLETED = of("transaction_cannot_be_completed") + + /** + * The transaction is a duplicate of a previous transaction and cannot be processed + * again. + */ + @JvmField val DUPLICATE_TRANSACTION = of("duplicate_transaction") + + /** + * A system malfunction occurred, preventing the transaction from being processed. + */ + @JvmField val SYSTEM_MALFUNCTION = of("system_malfunction") + + /** Additional customer authentication is required to complete the transaction. */ + @JvmField + val ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED = + of("additional_customer_authentication_required") + + /** + * The surcharge amount applied to the transaction is not permitted by the issuer. + */ + @JvmField val SURCHARGE_AMOUNT_NOT_PERMITTED = of("surcharge_amount_not_permitted") + + /** The transaction was declined due to a failure in verifying the CVV2 code. */ + @JvmField val DECLINE_FOR_CVV2_FAILURE = of("decline_for_cvv2_failure") + + /** A stop payment order has been placed on this transaction. */ + @JvmField val STOP_PAYMENT_ORDER = of("stop_payment_order") + + /** An order has been placed to revoke authorization for this transaction. */ + @JvmField + val REVOCATION_OF_AUTHORIZATION_ORDER = of("revocation_of_authorization_order") + + /** An order has been placed to revoke all authorizations for this cardholder. */ + @JvmField + val REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER = + of("revocation_of_all_authorizations_order") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** + * The card issuer has declined the transaction without providing a specific reason. + */ + DO_NOT_HONOR, + /** + * The number of transactions for the card has exceeded the limit set by the issuer. + */ + ACTIVITY_COUNT_LIMIT_EXCEEDED, + /** + * The card issuer requires the cardholder to contact them for further information + * regarding the transaction. + */ + REFER_TO_CARD_ISSUER, + /** + * The card issuer requires the cardholder to contact them due to a special + * condition related to the transaction. + */ + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION, + /** The merchant is not valid for this transaction. */ + INVALID_MERCHANT, + /** The card should be retained by the terminal. */ + PICK_UP_CARD, + /** An error occurred during processing of the transaction. */ + ERROR, + /** The card should be retained by the terminal due to a special condition. */ + PICK_UP_CARD_SPECIAL, + /** The transaction is invalid and cannot be processed. */ + INVALID_TRANSACTION, + /** The amount of the transaction is invalid. */ + INVALID_AMOUNT, + /** The account number provided is invalid. */ + INVALID_ACCOUNT_NUMBER, + /** The issuer of the card could not be found. */ + NO_SUCH_ISSUER, + /** The transaction should be re-entered for processing. */ + RE_ENTER_TRANSACTION, + /** There is no credit account associated with the card. */ + NO_CREDIT_ACCOUNT, + /** + * The card should be retained by the terminal because it has been reported lost. + */ + PICK_UP_CARD_LOST, + /** + * The card should be retained by the terminal because it has been reported stolen. + */ + PICK_UP_CARD_STOLEN, + /** The account associated with the card has been closed. */ + CLOSED_ACCOUNT, + /** There are insufficient funds in the account to complete the transaction. */ + INSUFFICIENT_FUNDS, + /** There is no checking account associated with the card. */ + NO_CHECKING_ACCOUNT, + /** There is no savings account associated with the card. */ + NO_SAVINGS_ACCOUNT, + /** The card has expired and cannot be used for transactions. */ + EXPIRED_CARD, + /** The transaction is not permitted for this cardholder. */ + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER, + /** The transaction is not allowed at this terminal. */ + TRANSACTION_NOT_ALLOWED_AT_TERMINAL, + /** The transaction has been flagged as suspected fraud and cannot be processed. */ + SUSPECTED_FRAUD, + /** The amount of activity on the card has exceeded the limit set by the issuer. */ + ACTIVITY_AMOUNT_LIMIT_EXCEEDED, + /** + * The card has restrictions that prevent it from being used for this transaction. + */ + RESTRICTED_CARD, + /** + * A security violation has occurred, preventing the transaction from being + * processed. + */ + SECURITY_VIOLATION, + /** + * The transaction does not meet the anti-money laundering requirements set by the + * issuer. + */ + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT, + /** The first use of the card has been blocked by the issuer. */ + BLOCKED_FIRST_USE, + /** The credit issuer is currently unavailable to process the transaction. */ + CREDIT_ISSUER_UNAVAILABLE, + /** + * The card verification value (CVV) results were negative, indicating a potential + * issue with the card. + */ + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS, + /** The issuer of the card is currently unavailable to process the transaction. */ + ISSUER_UNAVAILABLE, + /** The financial institution associated with the card could not be found. */ + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND, + /** The transaction cannot be completed due to an unspecified reason. */ + TRANSACTION_CANNOT_BE_COMPLETED, + /** + * The transaction is a duplicate of a previous transaction and cannot be processed + * again. + */ + DUPLICATE_TRANSACTION, + /** + * A system malfunction occurred, preventing the transaction from being processed. + */ + SYSTEM_MALFUNCTION, + /** Additional customer authentication is required to complete the transaction. */ + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED, + /** + * The surcharge amount applied to the transaction is not permitted by the issuer. + */ + SURCHARGE_AMOUNT_NOT_PERMITTED, + /** The transaction was declined due to a failure in verifying the CVV2 code. */ + DECLINE_FOR_CVV2_FAILURE, + /** A stop payment order has been placed on this transaction. */ + STOP_PAYMENT_ORDER, + /** An order has been placed to revoke authorization for this transaction. */ + REVOCATION_OF_AUTHORIZATION_ORDER, + /** An order has been placed to revoke all authorizations for this cardholder. */ + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] 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 card issuer has declined the transaction without providing a specific reason. + */ + DO_NOT_HONOR, + /** + * The number of transactions for the card has exceeded the limit set by the issuer. + */ + ACTIVITY_COUNT_LIMIT_EXCEEDED, + /** + * The card issuer requires the cardholder to contact them for further information + * regarding the transaction. + */ + REFER_TO_CARD_ISSUER, + /** + * The card issuer requires the cardholder to contact them due to a special + * condition related to the transaction. + */ + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION, + /** The merchant is not valid for this transaction. */ + INVALID_MERCHANT, + /** The card should be retained by the terminal. */ + PICK_UP_CARD, + /** An error occurred during processing of the transaction. */ + ERROR, + /** The card should be retained by the terminal due to a special condition. */ + PICK_UP_CARD_SPECIAL, + /** The transaction is invalid and cannot be processed. */ + INVALID_TRANSACTION, + /** The amount of the transaction is invalid. */ + INVALID_AMOUNT, + /** The account number provided is invalid. */ + INVALID_ACCOUNT_NUMBER, + /** The issuer of the card could not be found. */ + NO_SUCH_ISSUER, + /** The transaction should be re-entered for processing. */ + RE_ENTER_TRANSACTION, + /** There is no credit account associated with the card. */ + NO_CREDIT_ACCOUNT, + /** + * The card should be retained by the terminal because it has been reported lost. + */ + PICK_UP_CARD_LOST, + /** + * The card should be retained by the terminal because it has been reported stolen. + */ + PICK_UP_CARD_STOLEN, + /** The account associated with the card has been closed. */ + CLOSED_ACCOUNT, + /** There are insufficient funds in the account to complete the transaction. */ + INSUFFICIENT_FUNDS, + /** There is no checking account associated with the card. */ + NO_CHECKING_ACCOUNT, + /** There is no savings account associated with the card. */ + NO_SAVINGS_ACCOUNT, + /** The card has expired and cannot be used for transactions. */ + EXPIRED_CARD, + /** The transaction is not permitted for this cardholder. */ + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER, + /** The transaction is not allowed at this terminal. */ + TRANSACTION_NOT_ALLOWED_AT_TERMINAL, + /** The transaction has been flagged as suspected fraud and cannot be processed. */ + SUSPECTED_FRAUD, + /** The amount of activity on the card has exceeded the limit set by the issuer. */ + ACTIVITY_AMOUNT_LIMIT_EXCEEDED, + /** + * The card has restrictions that prevent it from being used for this transaction. + */ + RESTRICTED_CARD, + /** + * A security violation has occurred, preventing the transaction from being + * processed. + */ + SECURITY_VIOLATION, + /** + * The transaction does not meet the anti-money laundering requirements set by the + * issuer. + */ + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT, + /** The first use of the card has been blocked by the issuer. */ + BLOCKED_FIRST_USE, + /** The credit issuer is currently unavailable to process the transaction. */ + CREDIT_ISSUER_UNAVAILABLE, + /** + * The card verification value (CVV) results were negative, indicating a potential + * issue with the card. + */ + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS, + /** The issuer of the card is currently unavailable to process the transaction. */ + ISSUER_UNAVAILABLE, + /** The financial institution associated with the card could not be found. */ + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND, + /** The transaction cannot be completed due to an unspecified reason. */ + TRANSACTION_CANNOT_BE_COMPLETED, + /** + * The transaction is a duplicate of a previous transaction and cannot be processed + * again. + */ + DUPLICATE_TRANSACTION, + /** + * A system malfunction occurred, preventing the transaction from being processed. + */ + SYSTEM_MALFUNCTION, + /** Additional customer authentication is required to complete the transaction. */ + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED, + /** + * The surcharge amount applied to the transaction is not permitted by the issuer. + */ + SURCHARGE_AMOUNT_NOT_PERMITTED, + /** The transaction was declined due to a failure in verifying the CVV2 code. */ + DECLINE_FOR_CVV2_FAILURE, + /** A stop payment order has been placed on this transaction. */ + STOP_PAYMENT_ORDER, + /** An order has been placed to revoke authorization for this transaction. */ + REVOCATION_OF_AUTHORIZATION_ORDER, + /** An order has been placed to revoke all authorizations for this cardholder. */ + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER, + /** + * An enum member indicating that [Reason] 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) { + DO_NOT_HONOR -> Value.DO_NOT_HONOR + ACTIVITY_COUNT_LIMIT_EXCEEDED -> Value.ACTIVITY_COUNT_LIMIT_EXCEEDED + REFER_TO_CARD_ISSUER -> Value.REFER_TO_CARD_ISSUER + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION -> + Value.REFER_TO_CARD_ISSUER_SPECIAL_CONDITION + INVALID_MERCHANT -> Value.INVALID_MERCHANT + PICK_UP_CARD -> Value.PICK_UP_CARD + ERROR -> Value.ERROR + PICK_UP_CARD_SPECIAL -> Value.PICK_UP_CARD_SPECIAL + INVALID_TRANSACTION -> Value.INVALID_TRANSACTION + INVALID_AMOUNT -> Value.INVALID_AMOUNT + INVALID_ACCOUNT_NUMBER -> Value.INVALID_ACCOUNT_NUMBER + NO_SUCH_ISSUER -> Value.NO_SUCH_ISSUER + RE_ENTER_TRANSACTION -> Value.RE_ENTER_TRANSACTION + NO_CREDIT_ACCOUNT -> Value.NO_CREDIT_ACCOUNT + PICK_UP_CARD_LOST -> Value.PICK_UP_CARD_LOST + PICK_UP_CARD_STOLEN -> Value.PICK_UP_CARD_STOLEN + CLOSED_ACCOUNT -> Value.CLOSED_ACCOUNT + INSUFFICIENT_FUNDS -> Value.INSUFFICIENT_FUNDS + NO_CHECKING_ACCOUNT -> Value.NO_CHECKING_ACCOUNT + NO_SAVINGS_ACCOUNT -> Value.NO_SAVINGS_ACCOUNT + EXPIRED_CARD -> Value.EXPIRED_CARD + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER -> + Value.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + TRANSACTION_NOT_ALLOWED_AT_TERMINAL -> Value.TRANSACTION_NOT_ALLOWED_AT_TERMINAL + SUSPECTED_FRAUD -> Value.SUSPECTED_FRAUD + ACTIVITY_AMOUNT_LIMIT_EXCEEDED -> Value.ACTIVITY_AMOUNT_LIMIT_EXCEEDED + RESTRICTED_CARD -> Value.RESTRICTED_CARD + SECURITY_VIOLATION -> Value.SECURITY_VIOLATION + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT -> + Value.TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT + BLOCKED_FIRST_USE -> Value.BLOCKED_FIRST_USE + CREDIT_ISSUER_UNAVAILABLE -> Value.CREDIT_ISSUER_UNAVAILABLE + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS -> + Value.NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS + ISSUER_UNAVAILABLE -> Value.ISSUER_UNAVAILABLE + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND -> + Value.FINANCIAL_INSTITUTION_CANNOT_BE_FOUND + TRANSACTION_CANNOT_BE_COMPLETED -> Value.TRANSACTION_CANNOT_BE_COMPLETED + DUPLICATE_TRANSACTION -> Value.DUPLICATE_TRANSACTION + SYSTEM_MALFUNCTION -> Value.SYSTEM_MALFUNCTION + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED -> + Value.ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED + SURCHARGE_AMOUNT_NOT_PERMITTED -> Value.SURCHARGE_AMOUNT_NOT_PERMITTED + DECLINE_FOR_CVV2_FAILURE -> Value.DECLINE_FOR_CVV2_FAILURE + STOP_PAYMENT_ORDER -> Value.STOP_PAYMENT_ORDER + REVOCATION_OF_AUTHORIZATION_ORDER -> Value.REVOCATION_OF_AUTHORIZATION_ORDER + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER -> + Value.REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER + 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) { + DO_NOT_HONOR -> Known.DO_NOT_HONOR + ACTIVITY_COUNT_LIMIT_EXCEEDED -> Known.ACTIVITY_COUNT_LIMIT_EXCEEDED + REFER_TO_CARD_ISSUER -> Known.REFER_TO_CARD_ISSUER + REFER_TO_CARD_ISSUER_SPECIAL_CONDITION -> + Known.REFER_TO_CARD_ISSUER_SPECIAL_CONDITION + INVALID_MERCHANT -> Known.INVALID_MERCHANT + PICK_UP_CARD -> Known.PICK_UP_CARD + ERROR -> Known.ERROR + PICK_UP_CARD_SPECIAL -> Known.PICK_UP_CARD_SPECIAL + INVALID_TRANSACTION -> Known.INVALID_TRANSACTION + INVALID_AMOUNT -> Known.INVALID_AMOUNT + INVALID_ACCOUNT_NUMBER -> Known.INVALID_ACCOUNT_NUMBER + NO_SUCH_ISSUER -> Known.NO_SUCH_ISSUER + RE_ENTER_TRANSACTION -> Known.RE_ENTER_TRANSACTION + NO_CREDIT_ACCOUNT -> Known.NO_CREDIT_ACCOUNT + PICK_UP_CARD_LOST -> Known.PICK_UP_CARD_LOST + PICK_UP_CARD_STOLEN -> Known.PICK_UP_CARD_STOLEN + CLOSED_ACCOUNT -> Known.CLOSED_ACCOUNT + INSUFFICIENT_FUNDS -> Known.INSUFFICIENT_FUNDS + NO_CHECKING_ACCOUNT -> Known.NO_CHECKING_ACCOUNT + NO_SAVINGS_ACCOUNT -> Known.NO_SAVINGS_ACCOUNT + EXPIRED_CARD -> Known.EXPIRED_CARD + TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER -> + Known.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + TRANSACTION_NOT_ALLOWED_AT_TERMINAL -> Known.TRANSACTION_NOT_ALLOWED_AT_TERMINAL + SUSPECTED_FRAUD -> Known.SUSPECTED_FRAUD + ACTIVITY_AMOUNT_LIMIT_EXCEEDED -> Known.ACTIVITY_AMOUNT_LIMIT_EXCEEDED + RESTRICTED_CARD -> Known.RESTRICTED_CARD + SECURITY_VIOLATION -> Known.SECURITY_VIOLATION + TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT -> + Known.TRANSACTION_DOES_NOT_FULFILL_ANTI_MONEY_LAUNDERING_REQUIREMENT + BLOCKED_FIRST_USE -> Known.BLOCKED_FIRST_USE + CREDIT_ISSUER_UNAVAILABLE -> Known.CREDIT_ISSUER_UNAVAILABLE + NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS -> + Known.NEGATIVE_CARD_VERIFICATION_VALUE_RESULTS + ISSUER_UNAVAILABLE -> Known.ISSUER_UNAVAILABLE + FINANCIAL_INSTITUTION_CANNOT_BE_FOUND -> + Known.FINANCIAL_INSTITUTION_CANNOT_BE_FOUND + TRANSACTION_CANNOT_BE_COMPLETED -> Known.TRANSACTION_CANNOT_BE_COMPLETED + DUPLICATE_TRANSACTION -> Known.DUPLICATE_TRANSACTION + SYSTEM_MALFUNCTION -> Known.SYSTEM_MALFUNCTION + ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED -> + Known.ADDITIONAL_CUSTOMER_AUTHENTICATION_REQUIRED + SURCHARGE_AMOUNT_NOT_PERMITTED -> Known.SURCHARGE_AMOUNT_NOT_PERMITTED + DECLINE_FOR_CVV2_FAILURE -> Known.DECLINE_FOR_CVV2_FAILURE + STOP_PAYMENT_ORDER -> Known.STOP_PAYMENT_ORDER + REVOCATION_OF_AUTHORIZATION_ORDER -> Known.REVOCATION_OF_AUTHORIZATION_ORDER + REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER -> + Known.REVOCATION_OF_ALL_AUTHORIZATIONS_ORDER + else -> throw IncreaseInvalidDataException("Unknown Reason: $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(): Reason = 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 Reason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Decline && + declinedAt == other.declinedAt && + networkTransactionIdentifier == other.networkTransactionIdentifier && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(declinedAt, networkTransactionIdentifier, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Decline{declinedAt=$declinedAt, networkTransactionIdentifier=$networkTransactionIdentifier, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** The lifecycle status of the validation. */ + class Status @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 validation requires attention from an Increase operator. */ + @JvmField val REQUIRES_ATTENTION = of("requires_attention") + + /** The validation is queued to be submitted to the card network. */ + @JvmField val PENDING_SUBMISSION = of("pending_submission") + + /** + * The validation has been submitted and is pending a response from the card network. + */ + @JvmField val SUBMITTED = of("submitted") + + /** The validation has been sent successfully and is complete. */ + @JvmField val COMPLETE = of("complete") + + /** The validation was declined by the network or the recipient's bank. */ + @JvmField val DECLINED = of("declined") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + /** The validation requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The validation is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** + * The validation has been submitted and is pending a response from the card network. + */ + SUBMITTED, + /** The validation has been sent successfully and is complete. */ + COMPLETE, + /** The validation was declined by the network or the recipient's bank. */ + DECLINED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 validation requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The validation is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** + * The validation has been submitted and is pending a response from the card network. + */ + SUBMITTED, + /** The validation has been sent successfully and is complete. */ + COMPLETE, + /** The validation was declined by the network or the recipient's bank. */ + DECLINED, + /** An enum member indicating that [Status] 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) { + REQUIRES_ATTENTION -> Value.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Value.PENDING_SUBMISSION + SUBMITTED -> Value.SUBMITTED + COMPLETE -> Value.COMPLETE + DECLINED -> Value.DECLINED + 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) { + REQUIRES_ATTENTION -> Known.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Known.PENDING_SUBMISSION + SUBMITTED -> Known.SUBMITTED + COMPLETE -> Known.COMPLETE + DECLINED -> Known.DECLINED + else -> throw IncreaseInvalidDataException("Unknown Status: $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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * After the validation is submitted to the card network, this will contain supplemental + * details. + */ + class Submission + private constructor( + private val retrievalReferenceNumber: JsonField, + private val submittedAt: JsonField, + private val traceNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("retrieval_reference_number") + @ExcludeMissing + retrievalReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("submitted_at") + @ExcludeMissing + submittedAt: JsonField = JsonMissing.of(), + @JsonProperty("trace_number") + @ExcludeMissing + traceNumber: JsonField = JsonMissing.of(), + ) : this(retrievalReferenceNumber, submittedAt, traceNumber, mutableMapOf()) + + /** + * A 12-digit retrieval reference number that identifies the validation. Usually a + * combination of a timestamp and the trace number. + * + * @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 retrievalReferenceNumber(): String = + retrievalReferenceNumber.getRequired("retrieval_reference_number") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was submitted to the card network. + * + * @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 submittedAt(): OffsetDateTime = submittedAt.getRequired("submitted_at") + + /** + * A 6-digit trace number that identifies the validation within a short time window. + * + * @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 traceNumber(): String = traceNumber.getRequired("trace_number") + + /** + * Returns the raw JSON value of [retrievalReferenceNumber]. + * + * Unlike [retrievalReferenceNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("retrieval_reference_number") + @ExcludeMissing + fun _retrievalReferenceNumber(): JsonField = retrievalReferenceNumber + + /** + * Returns the raw JSON value of [submittedAt]. + * + * Unlike [submittedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("submitted_at") + @ExcludeMissing + fun _submittedAt(): JsonField = submittedAt + + /** + * Returns the raw JSON value of [traceNumber]. + * + * Unlike [traceNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_number") + @ExcludeMissing + fun _traceNumber(): JsonField = traceNumber + + @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 [Submission]. + * + * The following fields are required: + * ```java + * .retrievalReferenceNumber() + * .submittedAt() + * .traceNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Submission]. */ + class Builder internal constructor() { + + private var retrievalReferenceNumber: JsonField? = null + private var submittedAt: JsonField? = null + private var traceNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(submission: Submission) = apply { + retrievalReferenceNumber = submission.retrievalReferenceNumber + submittedAt = submission.submittedAt + traceNumber = submission.traceNumber + additionalProperties = submission.additionalProperties.toMutableMap() + } + + /** + * A 12-digit retrieval reference number that identifies the validation. Usually a + * combination of a timestamp and the trace number. + */ + fun retrievalReferenceNumber(retrievalReferenceNumber: String) = + retrievalReferenceNumber(JsonField.of(retrievalReferenceNumber)) + + /** + * Sets [Builder.retrievalReferenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.retrievalReferenceNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun retrievalReferenceNumber(retrievalReferenceNumber: JsonField) = apply { + this.retrievalReferenceNumber = retrievalReferenceNumber + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * validation was submitted to the card network. + */ + fun submittedAt(submittedAt: OffsetDateTime) = submittedAt(JsonField.of(submittedAt)) + + /** + * Sets [Builder.submittedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.submittedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun submittedAt(submittedAt: JsonField) = apply { + this.submittedAt = submittedAt + } + + /** A 6-digit trace number that identifies the validation within a short time window. */ + fun traceNumber(traceNumber: String) = traceNumber(JsonField.of(traceNumber)) + + /** + * Sets [Builder.traceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.traceNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceNumber(traceNumber: JsonField) = apply { + this.traceNumber = traceNumber + } + + 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 [Submission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .retrievalReferenceNumber() + * .submittedAt() + * .traceNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Submission = + Submission( + checkRequired("retrievalReferenceNumber", retrievalReferenceNumber), + checkRequired("submittedAt", submittedAt), + checkRequired("traceNumber", traceNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Submission = apply { + if (validated) { + return@apply + } + + retrievalReferenceNumber() + submittedAt() + traceNumber() + 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 (retrievalReferenceNumber.asKnown().isPresent) 1 else 0) + + (if (submittedAt.asKnown().isPresent) 1 else 0) + + (if (traceNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Submission && + retrievalReferenceNumber == other.retrievalReferenceNumber && + submittedAt == other.submittedAt && + traceNumber == other.traceNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(retrievalReferenceNumber, submittedAt, traceNumber, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Submission{retrievalReferenceNumber=$retrievalReferenceNumber, submittedAt=$submittedAt, traceNumber=$traceNumber, additionalProperties=$additionalProperties}" + } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_validation`. + */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD_VALIDATION = of("card_validation") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CARD_VALIDATION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD_VALIDATION, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD_VALIDATION -> Value.CARD_VALIDATION + 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) { + CARD_VALIDATION -> Known.CARD_VALIDATION + else -> throw IncreaseInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidation && + id == other.id && + acceptance == other.acceptance && + accountId == other.accountId && + cardholderFirstName == other.cardholderFirstName && + cardholderLastName == other.cardholderLastName && + cardholderMiddleName == other.cardholderMiddleName && + cardholderPostalCode == other.cardholderPostalCode && + cardholderStreetAddress == other.cardholderStreetAddress && + createdAt == other.createdAt && + createdBy == other.createdBy && + decline == other.decline && + idempotencyKey == other.idempotencyKey && + merchantCategoryCode == other.merchantCategoryCode && + merchantCityName == other.merchantCityName && + merchantName == other.merchantName && + merchantPostalCode == other.merchantPostalCode && + merchantState == other.merchantState && + status == other.status && + submission == other.submission && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + acceptance, + accountId, + cardholderFirstName, + cardholderLastName, + cardholderMiddleName, + cardholderPostalCode, + cardholderStreetAddress, + createdAt, + createdBy, + decline, + idempotencyKey, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantPostalCode, + merchantState, + status, + submission, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardValidation{id=$id, acceptance=$acceptance, accountId=$accountId, cardholderFirstName=$cardholderFirstName, cardholderLastName=$cardholderLastName, cardholderMiddleName=$cardholderMiddleName, cardholderPostalCode=$cardholderPostalCode, cardholderStreetAddress=$cardholderStreetAddress, createdAt=$createdAt, createdBy=$createdBy, decline=$decline, idempotencyKey=$idempotencyKey, merchantCategoryCode=$merchantCategoryCode, merchantCityName=$merchantCityName, merchantName=$merchantName, merchantPostalCode=$merchantPostalCode, merchantState=$merchantState, status=$status, submission=$submission, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationCreateParams.kt new file mode 100644 index 000000000..5dbba819b --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationCreateParams.kt @@ -0,0 +1,1320 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +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.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.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** Create a Card Validation */ +class CardValidationCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The identifier of the Account from which to send the validation. + * + * @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 accountId(): String = body.accountId() + + /** + * The Increase identifier for the Card Token that represents the card number you're validating. + * + * @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 cardTokenId(): String = body.cardTokenId() + + /** + * A four-digit code (MCC) identifying the type of business or service provided by the merchant. + * + * @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 merchantCategoryCode(): String = body.merchantCategoryCode() + + /** + * The city where the merchant (typically your business) is located. + * + * @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 merchantCityName(): String = body.merchantCityName() + + /** + * The merchant name that will appear in the cardholder’s statement descriptor. Typically your + * business name. + * + * @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 merchantName(): String = body.merchantName() + + /** + * The postal code for the merchant’s (typically your business’s) location. + * + * @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 merchantPostalCode(): String = body.merchantPostalCode() + + /** + * The U.S. state where the merchant (typically your business) is located. + * + * @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 merchantState(): String = body.merchantState() + + /** + * The cardholder's first name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderFirstName(): Optional = body.cardholderFirstName() + + /** + * The cardholder's last name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderLastName(): Optional = body.cardholderLastName() + + /** + * The cardholder's middle name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderMiddleName(): Optional = body.cardholderMiddleName() + + /** + * The postal code of the cardholder's address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderPostalCode(): Optional = body.cardholderPostalCode() + + /** + * The cardholder's street address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderStreetAddress(): Optional = body.cardholderStreetAddress() + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _accountId(): JsonField = body._accountId() + + /** + * Returns the raw JSON value of [cardTokenId]. + * + * Unlike [cardTokenId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _cardTokenId(): JsonField = body._cardTokenId() + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantCategoryCode(): JsonField = body._merchantCategoryCode() + + /** + * Returns the raw JSON value of [merchantCityName]. + * + * Unlike [merchantCityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantCityName(): JsonField = body._merchantCityName() + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _merchantName(): JsonField = body._merchantName() + + /** + * Returns the raw JSON value of [merchantPostalCode]. + * + * Unlike [merchantPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantPostalCode(): JsonField = body._merchantPostalCode() + + /** + * Returns the raw JSON value of [merchantState]. + * + * Unlike [merchantState], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _merchantState(): JsonField = body._merchantState() + + /** + * Returns the raw JSON value of [cardholderFirstName]. + * + * Unlike [cardholderFirstName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _cardholderFirstName(): JsonField = body._cardholderFirstName() + + /** + * Returns the raw JSON value of [cardholderLastName]. + * + * Unlike [cardholderLastName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _cardholderLastName(): JsonField = body._cardholderLastName() + + /** + * Returns the raw JSON value of [cardholderMiddleName]. + * + * Unlike [cardholderMiddleName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _cardholderMiddleName(): JsonField = body._cardholderMiddleName() + + /** + * Returns the raw JSON value of [cardholderPostalCode]. + * + * Unlike [cardholderPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _cardholderPostalCode(): JsonField = body._cardholderPostalCode() + + /** + * Returns the raw JSON value of [cardholderStreetAddress]. + * + * Unlike [cardholderStreetAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _cardholderStreetAddress(): JsonField = body._cardholderStreetAddress() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardValidationCreateParams]. + * + * The following fields are required: + * ```java + * .accountId() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantPostalCode() + * .merchantState() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidationCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardValidationCreateParams: CardValidationCreateParams) = apply { + body = cardValidationCreateParams.body.toBuilder() + additionalHeaders = cardValidationCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardValidationCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * 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] + * - [cardTokenId] + * - [merchantCategoryCode] + * - [merchantCityName] + * - [merchantName] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The identifier of the Account from which to send the validation. */ + fun accountId(accountId: String) = apply { body.accountId(accountId) } + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountId(accountId: JsonField) = apply { body.accountId(accountId) } + + /** + * The Increase identifier for the Card Token that represents the card number you're + * validating. + */ + fun cardTokenId(cardTokenId: String) = apply { body.cardTokenId(cardTokenId) } + + /** + * Sets [Builder.cardTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardTokenId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardTokenId(cardTokenId: JsonField) = apply { body.cardTokenId(cardTokenId) } + + /** + * A four-digit code (MCC) identifying the type of business or service provided by the + * merchant. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = apply { + body.merchantCategoryCode(merchantCategoryCode) + } + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = apply { + body.merchantCategoryCode(merchantCategoryCode) + } + + /** The city where the merchant (typically your business) is located. */ + fun merchantCityName(merchantCityName: String) = apply { + body.merchantCityName(merchantCityName) + } + + /** + * Sets [Builder.merchantCityName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCityName(merchantCityName: JsonField) = apply { + body.merchantCityName(merchantCityName) + } + + /** + * The merchant name that will appear in the cardholder’s statement descriptor. Typically + * your business name. + */ + fun merchantName(merchantName: String) = apply { body.merchantName(merchantName) } + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantName(merchantName: JsonField) = apply { + body.merchantName(merchantName) + } + + /** The postal code for the merchant’s (typically your business’s) location. */ + fun merchantPostalCode(merchantPostalCode: String) = apply { + body.merchantPostalCode(merchantPostalCode) + } + + /** + * Sets [Builder.merchantPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantPostalCode(merchantPostalCode: JsonField) = apply { + body.merchantPostalCode(merchantPostalCode) + } + + /** The U.S. state where the merchant (typically your business) is located. */ + fun merchantState(merchantState: String) = apply { body.merchantState(merchantState) } + + /** + * Sets [Builder.merchantState] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantState] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantState(merchantState: JsonField) = apply { + body.merchantState(merchantState) + } + + /** The cardholder's first name. */ + fun cardholderFirstName(cardholderFirstName: String) = apply { + body.cardholderFirstName(cardholderFirstName) + } + + /** + * Sets [Builder.cardholderFirstName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderFirstName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderFirstName(cardholderFirstName: JsonField) = apply { + body.cardholderFirstName(cardholderFirstName) + } + + /** The cardholder's last name. */ + fun cardholderLastName(cardholderLastName: String) = apply { + body.cardholderLastName(cardholderLastName) + } + + /** + * Sets [Builder.cardholderLastName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderLastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderLastName(cardholderLastName: JsonField) = apply { + body.cardholderLastName(cardholderLastName) + } + + /** The cardholder's middle name. */ + fun cardholderMiddleName(cardholderMiddleName: String) = apply { + body.cardholderMiddleName(cardholderMiddleName) + } + + /** + * Sets [Builder.cardholderMiddleName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderMiddleName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderMiddleName(cardholderMiddleName: JsonField) = apply { + body.cardholderMiddleName(cardholderMiddleName) + } + + /** The postal code of the cardholder's address. */ + fun cardholderPostalCode(cardholderPostalCode: String) = apply { + body.cardholderPostalCode(cardholderPostalCode) + } + + /** + * Sets [Builder.cardholderPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderPostalCode(cardholderPostalCode: JsonField) = apply { + body.cardholderPostalCode(cardholderPostalCode) + } + + /** The cardholder's street address. */ + fun cardholderStreetAddress(cardholderStreetAddress: String) = apply { + body.cardholderStreetAddress(cardholderStreetAddress) + } + + /** + * Sets [Builder.cardholderStreetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderStreetAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cardholderStreetAddress(cardholderStreetAddress: JsonField) = apply { + body.cardholderStreetAddress(cardholderStreetAddress) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardValidationCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountId() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantPostalCode() + * .merchantState() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardValidationCreateParams = + CardValidationCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val accountId: JsonField, + private val cardTokenId: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCityName: JsonField, + private val merchantName: JsonField, + private val merchantPostalCode: JsonField, + private val merchantState: JsonField, + private val cardholderFirstName: JsonField, + private val cardholderLastName: JsonField, + private val cardholderMiddleName: JsonField, + private val cardholderPostalCode: JsonField, + private val cardholderStreetAddress: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_id") + @ExcludeMissing + accountId: JsonField = JsonMissing.of(), + @JsonProperty("card_token_id") + @ExcludeMissing + cardTokenId: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_city_name") + @ExcludeMissing + merchantCityName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name") + @ExcludeMissing + merchantName: JsonField = JsonMissing.of(), + @JsonProperty("merchant_postal_code") + @ExcludeMissing + merchantPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_state") + @ExcludeMissing + merchantState: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_first_name") + @ExcludeMissing + cardholderFirstName: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_last_name") + @ExcludeMissing + cardholderLastName: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_middle_name") + @ExcludeMissing + cardholderMiddleName: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_postal_code") + @ExcludeMissing + cardholderPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_street_address") + @ExcludeMissing + cardholderStreetAddress: JsonField = JsonMissing.of(), + ) : this( + accountId, + cardTokenId, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantPostalCode, + merchantState, + cardholderFirstName, + cardholderLastName, + cardholderMiddleName, + cardholderPostalCode, + cardholderStreetAddress, + mutableMapOf(), + ) + + /** + * The identifier of the Account from which to send the validation. + * + * @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 accountId(): String = accountId.getRequired("account_id") + + /** + * The Increase identifier for the Card Token that represents the card number you're + * validating. + * + * @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 cardTokenId(): String = cardTokenId.getRequired("card_token_id") + + /** + * A four-digit code (MCC) identifying the type of business or service provided by the + * merchant. + * + * @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 merchantCategoryCode(): String = + merchantCategoryCode.getRequired("merchant_category_code") + + /** + * The city where the merchant (typically your business) is located. + * + * @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 merchantCityName(): String = merchantCityName.getRequired("merchant_city_name") + + /** + * The merchant name that will appear in the cardholder’s statement descriptor. Typically + * your business name. + * + * @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 merchantName(): String = merchantName.getRequired("merchant_name") + + /** + * The postal code for the merchant’s (typically your business’s) location. + * + * @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 merchantPostalCode(): String = merchantPostalCode.getRequired("merchant_postal_code") + + /** + * The U.S. state where the merchant (typically your business) is located. + * + * @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 merchantState(): String = merchantState.getRequired("merchant_state") + + /** + * The cardholder's first name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderFirstName(): Optional = + cardholderFirstName.getOptional("cardholder_first_name") + + /** + * The cardholder's last name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderLastName(): Optional = + cardholderLastName.getOptional("cardholder_last_name") + + /** + * The cardholder's middle name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderMiddleName(): Optional = + cardholderMiddleName.getOptional("cardholder_middle_name") + + /** + * The postal code of the cardholder's address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderPostalCode(): Optional = + cardholderPostalCode.getOptional("cardholder_postal_code") + + /** + * The cardholder's street address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholderStreetAddress(): Optional = + cardholderStreetAddress.getOptional("cardholder_street_address") + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [cardTokenId]. + * + * Unlike [cardTokenId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token_id") + @ExcludeMissing + fun _cardTokenId(): JsonField = cardTokenId + + /** + * 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 [merchantCityName]. + * + * Unlike [merchantCityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_city_name") + @ExcludeMissing + fun _merchantCityName(): JsonField = merchantCityName + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_name") + @ExcludeMissing + fun _merchantName(): JsonField = merchantName + + /** + * Returns the raw JSON value of [merchantPostalCode]. + * + * Unlike [merchantPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_postal_code") + @ExcludeMissing + fun _merchantPostalCode(): JsonField = merchantPostalCode + + /** + * Returns the raw JSON value of [merchantState]. + * + * Unlike [merchantState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_state") + @ExcludeMissing + fun _merchantState(): JsonField = merchantState + + /** + * Returns the raw JSON value of [cardholderFirstName]. + * + * Unlike [cardholderFirstName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_first_name") + @ExcludeMissing + fun _cardholderFirstName(): JsonField = cardholderFirstName + + /** + * Returns the raw JSON value of [cardholderLastName]. + * + * Unlike [cardholderLastName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_last_name") + @ExcludeMissing + fun _cardholderLastName(): JsonField = cardholderLastName + + /** + * Returns the raw JSON value of [cardholderMiddleName]. + * + * Unlike [cardholderMiddleName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_middle_name") + @ExcludeMissing + fun _cardholderMiddleName(): JsonField = cardholderMiddleName + + /** + * Returns the raw JSON value of [cardholderPostalCode]. + * + * Unlike [cardholderPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_postal_code") + @ExcludeMissing + fun _cardholderPostalCode(): JsonField = cardholderPostalCode + + /** + * Returns the raw JSON value of [cardholderStreetAddress]. + * + * Unlike [cardholderStreetAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_street_address") + @ExcludeMissing + fun _cardholderStreetAddress(): JsonField = cardholderStreetAddress + + @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 [Body]. + * + * The following fields are required: + * ```java + * .accountId() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantPostalCode() + * .merchantState() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var accountId: JsonField? = null + private var cardTokenId: JsonField? = null + private var merchantCategoryCode: JsonField? = null + private var merchantCityName: JsonField? = null + private var merchantName: JsonField? = null + private var merchantPostalCode: JsonField? = null + private var merchantState: JsonField? = null + private var cardholderFirstName: JsonField = JsonMissing.of() + private var cardholderLastName: JsonField = JsonMissing.of() + private var cardholderMiddleName: JsonField = JsonMissing.of() + private var cardholderPostalCode: JsonField = JsonMissing.of() + private var cardholderStreetAddress: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + accountId = body.accountId + cardTokenId = body.cardTokenId + merchantCategoryCode = body.merchantCategoryCode + merchantCityName = body.merchantCityName + merchantName = body.merchantName + merchantPostalCode = body.merchantPostalCode + merchantState = body.merchantState + cardholderFirstName = body.cardholderFirstName + cardholderLastName = body.cardholderLastName + cardholderMiddleName = body.cardholderMiddleName + cardholderPostalCode = body.cardholderPostalCode + cardholderStreetAddress = body.cardholderStreetAddress + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The identifier of the Account from which to send the validation. */ + fun accountId(accountId: String) = accountId(JsonField.of(accountId)) + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountId(accountId: JsonField) = apply { this.accountId = accountId } + + /** + * The Increase identifier for the Card Token that represents the card number you're + * validating. + */ + fun cardTokenId(cardTokenId: String) = cardTokenId(JsonField.of(cardTokenId)) + + /** + * Sets [Builder.cardTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardTokenId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardTokenId(cardTokenId: JsonField) = apply { + this.cardTokenId = cardTokenId + } + + /** + * A four-digit code (MCC) identifying the type of business or service provided by the + * merchant. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] + * 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 + } + + /** The city where the merchant (typically your business) is located. */ + fun merchantCityName(merchantCityName: String) = + merchantCityName(JsonField.of(merchantCityName)) + + /** + * Sets [Builder.merchantCityName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCityName(merchantCityName: JsonField) = apply { + this.merchantCityName = merchantCityName + } + + /** + * The merchant name that will appear in the cardholder’s statement descriptor. + * Typically your business name. + */ + fun merchantName(merchantName: String) = merchantName(JsonField.of(merchantName)) + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantName(merchantName: JsonField) = apply { + this.merchantName = merchantName + } + + /** The postal code for the merchant’s (typically your business’s) location. */ + fun merchantPostalCode(merchantPostalCode: String) = + merchantPostalCode(JsonField.of(merchantPostalCode)) + + /** + * Sets [Builder.merchantPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantPostalCode(merchantPostalCode: JsonField) = apply { + this.merchantPostalCode = merchantPostalCode + } + + /** The U.S. state where the merchant (typically your business) is located. */ + fun merchantState(merchantState: String) = merchantState(JsonField.of(merchantState)) + + /** + * Sets [Builder.merchantState] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantState(merchantState: JsonField) = apply { + this.merchantState = merchantState + } + + /** The cardholder's first name. */ + fun cardholderFirstName(cardholderFirstName: String) = + cardholderFirstName(JsonField.of(cardholderFirstName)) + + /** + * Sets [Builder.cardholderFirstName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderFirstName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cardholderFirstName(cardholderFirstName: JsonField) = apply { + this.cardholderFirstName = cardholderFirstName + } + + /** The cardholder's last name. */ + fun cardholderLastName(cardholderLastName: String) = + cardholderLastName(JsonField.of(cardholderLastName)) + + /** + * Sets [Builder.cardholderLastName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderLastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderLastName(cardholderLastName: JsonField) = apply { + this.cardholderLastName = cardholderLastName + } + + /** The cardholder's middle name. */ + fun cardholderMiddleName(cardholderMiddleName: String) = + cardholderMiddleName(JsonField.of(cardholderMiddleName)) + + /** + * Sets [Builder.cardholderMiddleName] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderMiddleName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cardholderMiddleName(cardholderMiddleName: JsonField) = apply { + this.cardholderMiddleName = cardholderMiddleName + } + + /** The postal code of the cardholder's address. */ + fun cardholderPostalCode(cardholderPostalCode: String) = + cardholderPostalCode(JsonField.of(cardholderPostalCode)) + + /** + * Sets [Builder.cardholderPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPostalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cardholderPostalCode(cardholderPostalCode: JsonField) = apply { + this.cardholderPostalCode = cardholderPostalCode + } + + /** The cardholder's street address. */ + fun cardholderStreetAddress(cardholderStreetAddress: String) = + cardholderStreetAddress(JsonField.of(cardholderStreetAddress)) + + /** + * Sets [Builder.cardholderStreetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderStreetAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cardholderStreetAddress(cardholderStreetAddress: JsonField) = apply { + this.cardholderStreetAddress = cardholderStreetAddress + } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountId() + * .cardTokenId() + * .merchantCategoryCode() + * .merchantCityName() + * .merchantName() + * .merchantPostalCode() + * .merchantState() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("accountId", accountId), + checkRequired("cardTokenId", cardTokenId), + checkRequired("merchantCategoryCode", merchantCategoryCode), + checkRequired("merchantCityName", merchantCityName), + checkRequired("merchantName", merchantName), + checkRequired("merchantPostalCode", merchantPostalCode), + checkRequired("merchantState", merchantState), + cardholderFirstName, + cardholderLastName, + cardholderMiddleName, + cardholderPostalCode, + cardholderStreetAddress, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accountId() + cardTokenId() + merchantCategoryCode() + merchantCityName() + merchantName() + merchantPostalCode() + merchantState() + cardholderFirstName() + cardholderLastName() + cardholderMiddleName() + cardholderPostalCode() + cardholderStreetAddress() + 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 (accountId.asKnown().isPresent) 1 else 0) + + (if (cardTokenId.asKnown().isPresent) 1 else 0) + + (if (merchantCategoryCode.asKnown().isPresent) 1 else 0) + + (if (merchantCityName.asKnown().isPresent) 1 else 0) + + (if (merchantName.asKnown().isPresent) 1 else 0) + + (if (merchantPostalCode.asKnown().isPresent) 1 else 0) + + (if (merchantState.asKnown().isPresent) 1 else 0) + + (if (cardholderFirstName.asKnown().isPresent) 1 else 0) + + (if (cardholderLastName.asKnown().isPresent) 1 else 0) + + (if (cardholderMiddleName.asKnown().isPresent) 1 else 0) + + (if (cardholderPostalCode.asKnown().isPresent) 1 else 0) + + (if (cardholderStreetAddress.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + accountId == other.accountId && + cardTokenId == other.cardTokenId && + merchantCategoryCode == other.merchantCategoryCode && + merchantCityName == other.merchantCityName && + merchantName == other.merchantName && + merchantPostalCode == other.merchantPostalCode && + merchantState == other.merchantState && + cardholderFirstName == other.cardholderFirstName && + cardholderLastName == other.cardholderLastName && + cardholderMiddleName == other.cardholderMiddleName && + cardholderPostalCode == other.cardholderPostalCode && + cardholderStreetAddress == other.cardholderStreetAddress && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountId, + cardTokenId, + merchantCategoryCode, + merchantCityName, + merchantName, + merchantPostalCode, + merchantState, + cardholderFirstName, + cardholderLastName, + cardholderMiddleName, + cardholderPostalCode, + cardholderStreetAddress, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{accountId=$accountId, cardTokenId=$cardTokenId, merchantCategoryCode=$merchantCategoryCode, merchantCityName=$merchantCityName, merchantName=$merchantName, merchantPostalCode=$merchantPostalCode, merchantState=$merchantState, cardholderFirstName=$cardholderFirstName, cardholderLastName=$cardholderLastName, cardholderMiddleName=$cardholderMiddleName, cardholderPostalCode=$cardholderPostalCode, cardholderStreetAddress=$cardholderStreetAddress, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidationCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardValidationCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPage.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPage.kt new file mode 100644 index 000000000..e1688cd1d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.increase.api.core.AutoPager +import com.increase.api.core.Page +import com.increase.api.core.checkRequired +import com.increase.api.services.blocking.CardValidationService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see CardValidationService.list */ +class CardValidationListPage +private constructor( + private val service: CardValidationService, + private val params: CardValidationListParams, + private val response: CardValidationListPageResponse, +) : Page { + + /** + * Delegates to [CardValidationListPageResponse], but gracefully handles missing data. + * + * @see CardValidationListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardValidationListPageResponse], but gracefully handles missing data. + * + * @see CardValidationListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardValidationListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CardValidationListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): CardValidationListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardValidationListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardValidationListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidationListPage]. */ + class Builder internal constructor() { + + private var service: CardValidationService? = null + private var params: CardValidationListParams? = null + private var response: CardValidationListPageResponse? = null + + @JvmSynthetic + internal fun from(cardValidationListPage: CardValidationListPage) = apply { + service = cardValidationListPage.service + params = cardValidationListPage.params + response = cardValidationListPage.response + } + + fun service(service: CardValidationService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CardValidationListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardValidationListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardValidationListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardValidationListPage = + CardValidationListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidationListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "CardValidationListPage{service=$service, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageAsync.kt new file mode 100644 index 000000000..138cf333d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.increase.api.core.AutoPagerAsync +import com.increase.api.core.PageAsync +import com.increase.api.core.checkRequired +import com.increase.api.services.async.CardValidationServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see CardValidationServiceAsync.list */ +class CardValidationListPageAsync +private constructor( + private val service: CardValidationServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: CardValidationListParams, + private val response: CardValidationListPageResponse, +) : PageAsync { + + /** + * Delegates to [CardValidationListPageResponse], but gracefully handles missing data. + * + * @see CardValidationListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardValidationListPageResponse], but gracefully handles missing data. + * + * @see CardValidationListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardValidationListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): CardValidationListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardValidationListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardValidationListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidationListPageAsync]. */ + class Builder internal constructor() { + + private var service: CardValidationServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: CardValidationListParams? = null + private var response: CardValidationListPageResponse? = null + + @JvmSynthetic + internal fun from(cardValidationListPageAsync: CardValidationListPageAsync) = apply { + service = cardValidationListPageAsync.service + streamHandlerExecutor = cardValidationListPageAsync.streamHandlerExecutor + params = cardValidationListPageAsync.params + response = cardValidationListPageAsync.response + } + + fun service(service: CardValidationServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: CardValidationListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardValidationListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardValidationListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardValidationListPageAsync = + CardValidationListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidationListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "CardValidationListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageResponse.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageResponse.kt new file mode 100644 index 000000000..3e30f72c3 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageResponse.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +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.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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A list of Card Validation objects. */ +class CardValidationListPageResponse +private constructor( + private val data: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + ) : this(data, nextCursor, mutableMapOf()) + + /** + * The contents of the list. + * + * @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 data(): List = data.getRequired("data") + + /** + * A pointer to a place in the list. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @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 + * [CardValidationListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidationListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardValidationListPageResponse: CardValidationListPageResponse) = apply { + data = cardValidationListPageResponse.data.map { it.toMutableList() } + nextCursor = cardValidationListPageResponse.nextCursor + additionalProperties = + cardValidationListPageResponse.additionalProperties.toMutableMap() + } + + /** The contents of the list. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CardValidation] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CardValidation) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** A pointer to a place in the list. */ + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + /** Alias for calling [Builder.nextCursor] with `nextCursor.orElse(null)`. */ + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.getOrNull()) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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 [CardValidationListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardValidationListPageResponse = + CardValidationListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextCursor", nextCursor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardValidationListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextCursor() + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidationListPageResponse && + data == other.data && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextCursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardValidationListPageResponse{data=$data, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListParams.kt new file mode 100644 index 000000000..cb3f5caa9 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationListParams.kt @@ -0,0 +1,804 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.fasterxml.jackson.annotation.JsonCreator +import com.increase.api.core.Enum +import com.increase.api.core.JsonField +import com.increase.api.core.Params +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.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Card Validations */ +class CardValidationListParams +private constructor( + private val accountId: String?, + private val createdAt: CreatedAt?, + private val cursor: String?, + private val idempotencyKey: String?, + private val limit: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Filter Card Validations to ones belonging to the specified Account. */ + fun accountId(): Optional = Optional.ofNullable(accountId) + + fun createdAt(): Optional = Optional.ofNullable(createdAt) + + /** Return the page of entries after this one. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only processed + * once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(): Optional = Optional.ofNullable(idempotencyKey) + + /** Limit the size of the list that is returned. The default (and maximum) is 100 objects. */ + fun limit(): Optional = Optional.ofNullable(limit) + + fun status(): Optional = Optional.ofNullable(status) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardValidationListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CardValidationListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidationListParams]. */ + class Builder internal constructor() { + + private var accountId: String? = null + private var createdAt: CreatedAt? = null + private var cursor: String? = null + private var idempotencyKey: String? = null + private var limit: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardValidationListParams: CardValidationListParams) = apply { + accountId = cardValidationListParams.accountId + createdAt = cardValidationListParams.createdAt + cursor = cardValidationListParams.cursor + idempotencyKey = cardValidationListParams.idempotencyKey + limit = cardValidationListParams.limit + status = cardValidationListParams.status + additionalHeaders = cardValidationListParams.additionalHeaders.toBuilder() + additionalQueryParams = cardValidationListParams.additionalQueryParams.toBuilder() + } + + /** Filter Card Validations to ones belonging to the specified Account. */ + fun accountId(accountId: String?) = apply { this.accountId = accountId } + + /** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */ + fun accountId(accountId: Optional) = accountId(accountId.getOrNull()) + + fun createdAt(createdAt: CreatedAt?) = apply { this.createdAt = createdAt } + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** Return the page of entries after this one. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only + * processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = apply { this.idempotencyKey = idempotencyKey } + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Limit the size of the list that is returned. The default (and maximum) is 100 objects. + */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardValidationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardValidationListParams = + CardValidationListParams( + accountId, + createdAt, + cursor, + idempotencyKey, + limit, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + accountId?.let { put("account_id", it) } + createdAt?.let { + it.after().ifPresent { + put("created_at.after", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.before().ifPresent { + put("created_at.before", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.onOrAfter().ifPresent { + put( + "created_at.on_or_after", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it.onOrBefore().ifPresent { + put( + "created_at.on_or_before", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("created_at.$key", value) + } + } + } + cursor?.let { put("cursor", it) } + idempotencyKey?.let { put("idempotency_key", it) } + limit?.let { put("limit", it.toString()) } + status?.let { + it.in_().ifPresent { put("status.in", it.joinToString(",") { it.toString() }) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("status.$key", value) + } + } + } + putAll(additionalQueryParams) + } + .build() + + class CreatedAt + private constructor( + private val after: OffsetDateTime?, + private val before: OffsetDateTime?, + private val onOrAfter: OffsetDateTime?, + private val onOrBefore: OffsetDateTime?, + private val additionalProperties: QueryParams, + ) { + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun after(): Optional = Optional.ofNullable(after) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun before(): Optional = Optional.ofNullable(before) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(): Optional = Optional.ofNullable(onOrAfter) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(): Optional = Optional.ofNullable(onOrBefore) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreatedAt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedAt]. */ + class Builder internal constructor() { + + private var after: OffsetDateTime? = null + private var before: OffsetDateTime? = null + private var onOrAfter: OffsetDateTime? = null + private var onOrBefore: OffsetDateTime? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(createdAt: CreatedAt) = apply { + after = createdAt.after + before = createdAt.before + onOrAfter = createdAt.onOrAfter + onOrBefore = createdAt.onOrBefore + additionalProperties = createdAt.additionalProperties.toBuilder() + } + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun after(after: OffsetDateTime?) = apply { this.after = after } + + /** Alias for calling [Builder.after] with `after.orElse(null)`. */ + fun after(after: Optional) = after(after.getOrNull()) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun before(before: OffsetDateTime?) = apply { this.before = before } + + /** Alias for calling [Builder.before] with `before.orElse(null)`. */ + fun before(before: Optional) = before(before.getOrNull()) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(onOrAfter: OffsetDateTime?) = apply { this.onOrAfter = onOrAfter } + + /** Alias for calling [Builder.onOrAfter] with `onOrAfter.orElse(null)`. */ + fun onOrAfter(onOrAfter: Optional) = onOrAfter(onOrAfter.getOrNull()) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(onOrBefore: OffsetDateTime?) = apply { this.onOrBefore = onOrBefore } + + /** Alias for calling [Builder.onOrBefore] with `onOrBefore.orElse(null)`. */ + fun onOrBefore(onOrBefore: Optional) = + onOrBefore(onOrBefore.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreatedAt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreatedAt = + CreatedAt(after, before, onOrAfter, onOrBefore, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedAt && + after == other.after && + before == other.before && + onOrAfter == other.onOrAfter && + onOrBefore == other.onOrBefore && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(after, before, onOrAfter, onOrBefore, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedAt{after=$after, before=$before, onOrAfter=$onOrAfter, onOrBefore=$onOrBefore, additionalProperties=$additionalProperties}" + } + + class Status + private constructor(private val in_: List?, private val additionalProperties: QueryParams) { + + /** + * Filter Card Validations by status. For GET requests, this should be encoded as a + * comma-delimited string, such as `?in=one,two,three`. + */ + fun in_(): Optional> = Optional.ofNullable(in_) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Status]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var in_: MutableList? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(status: Status) = apply { + in_ = status.in_?.toMutableList() + additionalProperties = status.additionalProperties.toBuilder() + } + + /** + * Filter Card Validations by status. For GET requests, this should be encoded as a + * comma-delimited string, such as `?in=one,two,three`. + */ + fun in_(in_: List?) = apply { this.in_ = in_?.toMutableList() } + + /** Alias for calling [Builder.in_] with `in_.orElse(null)`. */ + fun in_(in_: Optional>) = in_(in_.getOrNull()) + + /** + * Adds a single [In] to [Builder.in_]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIn(in_: In) = apply { + this.in_ = (this.in_ ?: mutableListOf()).apply { add(in_) } + } + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Status = Status(in_?.toImmutable(), additionalProperties.build()) + } + + class In @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 validation requires attention from an Increase operator. */ + @JvmField val REQUIRES_ATTENTION = of("requires_attention") + + /** The validation is queued to be submitted to the card network. */ + @JvmField val PENDING_SUBMISSION = of("pending_submission") + + /** + * The validation has been submitted and is pending a response from the card + * network. + */ + @JvmField val SUBMITTED = of("submitted") + + /** The validation has been sent successfully and is complete. */ + @JvmField val COMPLETE = of("complete") + + /** The validation was declined by the network or the recipient's bank. */ + @JvmField val DECLINED = of("declined") + + @JvmStatic fun of(value: String) = In(JsonField.of(value)) + } + + /** An enum containing [In]'s known values. */ + enum class Known { + /** The validation requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The validation is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** + * The validation has been submitted and is pending a response from the card + * network. + */ + SUBMITTED, + /** The validation has been sent successfully and is complete. */ + COMPLETE, + /** The validation was declined by the network or the recipient's bank. */ + DECLINED, + } + + /** + * An enum containing [In]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [In] 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 validation requires attention from an Increase operator. */ + REQUIRES_ATTENTION, + /** The validation is queued to be submitted to the card network. */ + PENDING_SUBMISSION, + /** + * The validation has been submitted and is pending a response from the card + * network. + */ + SUBMITTED, + /** The validation has been sent successfully and is complete. */ + COMPLETE, + /** The validation was declined by the network or the recipient's bank. */ + DECLINED, + /** An enum member indicating that [In] 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) { + REQUIRES_ATTENTION -> Value.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Value.PENDING_SUBMISSION + SUBMITTED -> Value.SUBMITTED + COMPLETE -> Value.COMPLETE + DECLINED -> Value.DECLINED + 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) { + REQUIRES_ATTENTION -> Known.REQUIRES_ATTENTION + PENDING_SUBMISSION -> Known.PENDING_SUBMISSION + SUBMITTED -> Known.SUBMITTED + COMPLETE -> Known.COMPLETE + DECLINED -> Known.DECLINED + else -> throw IncreaseInvalidDataException("Unknown In: $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(): In = 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 In && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && + in_ == other.in_ && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(in_, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Status{in_=$in_, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidationListParams && + accountId == other.accountId && + createdAt == other.createdAt && + cursor == other.cursor && + idempotencyKey == other.idempotencyKey && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + accountId, + createdAt, + cursor, + idempotencyKey, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CardValidationListParams{accountId=$accountId, createdAt=$createdAt, cursor=$cursor, idempotencyKey=$idempotencyKey, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationRetrieveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationRetrieveParams.kt new file mode 100644 index 000000000..65d336904 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardvalidations/CardValidationRetrieveParams.kt @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a Card Validation */ +class CardValidationRetrieveParams +private constructor( + private val cardValidationId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Validation. */ + fun cardValidationId(): Optional = Optional.ofNullable(cardValidationId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardValidationRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardValidationRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardValidationRetrieveParams]. */ + class Builder internal constructor() { + + private var cardValidationId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardValidationRetrieveParams: CardValidationRetrieveParams) = apply { + cardValidationId = cardValidationRetrieveParams.cardValidationId + additionalHeaders = cardValidationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = cardValidationRetrieveParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Validation. */ + fun cardValidationId(cardValidationId: String?) = apply { + this.cardValidationId = cardValidationId + } + + /** Alias for calling [Builder.cardValidationId] with `cardValidationId.orElse(null)`. */ + fun cardValidationId(cardValidationId: Optional) = + cardValidationId(cardValidationId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardValidationRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardValidationRetrieveParams = + CardValidationRetrieveParams( + cardValidationId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardValidationId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardValidationRetrieveParams && + cardValidationId == other.cardValidationId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardValidationId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardValidationRetrieveParams{cardValidationId=$cardValidationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardtokens/CardTokenCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardtokens/CardTokenCreateParams.kt new file mode 100644 index 000000000..75af718f5 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardtokens/CardTokenCreateParams.kt @@ -0,0 +1,1399 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardtokens + +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.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Simulates tokenizing a card in the sandbox environment. */ +class CardTokenCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The capabilities of the outbound card token. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun capabilities(): Optional> = body.capabilities() + + /** + * The expiration date of the card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiration(): Optional = body.expiration() + + /** + * The last 4 digits of the card number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun last4(): Optional = body.last4() + + /** + * The prefix of the card number, usually the first 8 digits. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prefix(): Optional = body.prefix() + + /** + * The total length of the card number, including prefix and last4. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun primaryAccountNumberLength(): Optional = body.primaryAccountNumberLength() + + /** + * Returns the raw JSON value of [capabilities]. + * + * Unlike [capabilities], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _capabilities(): JsonField> = body._capabilities() + + /** + * Returns the raw JSON value of [expiration]. + * + * Unlike [expiration], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _expiration(): JsonField = body._expiration() + + /** + * Returns the raw JSON value of [last4]. + * + * Unlike [last4], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _last4(): JsonField = body._last4() + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _prefix(): JsonField = body._prefix() + + /** + * Returns the raw JSON value of [primaryAccountNumberLength]. + * + * Unlike [primaryAccountNumberLength], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _primaryAccountNumberLength(): JsonField = body._primaryAccountNumberLength() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardTokenCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CardTokenCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTokenCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardTokenCreateParams: CardTokenCreateParams) = apply { + body = cardTokenCreateParams.body.toBuilder() + additionalHeaders = cardTokenCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardTokenCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * 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: + * - [capabilities] + * - [expiration] + * - [last4] + * - [prefix] + * - [primaryAccountNumberLength] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The capabilities of the outbound card token. */ + fun capabilities(capabilities: List) = apply { body.capabilities(capabilities) } + + /** + * Sets [Builder.capabilities] to an arbitrary JSON value. + * + * You should usually call [Builder.capabilities] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun capabilities(capabilities: JsonField>) = apply { + body.capabilities(capabilities) + } + + /** + * Adds a single [Capability] to [capabilities]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCapability(capability: Capability) = apply { body.addCapability(capability) } + + /** The expiration date of the card. */ + fun expiration(expiration: LocalDate) = apply { body.expiration(expiration) } + + /** + * Sets [Builder.expiration] to an arbitrary JSON value. + * + * You should usually call [Builder.expiration] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expiration(expiration: JsonField) = apply { body.expiration(expiration) } + + /** The last 4 digits of the card number. */ + fun last4(last4: String) = apply { body.last4(last4) } + + /** + * Sets [Builder.last4] to an arbitrary JSON value. + * + * You should usually call [Builder.last4] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun last4(last4: JsonField) = apply { body.last4(last4) } + + /** The prefix of the card number, usually the first 8 digits. */ + fun prefix(prefix: String) = apply { body.prefix(prefix) } + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun prefix(prefix: JsonField) = apply { body.prefix(prefix) } + + /** The total length of the card number, including prefix and last4. */ + fun primaryAccountNumberLength(primaryAccountNumberLength: Long) = apply { + body.primaryAccountNumberLength(primaryAccountNumberLength) + } + + /** + * Sets [Builder.primaryAccountNumberLength] to an arbitrary JSON value. + * + * You should usually call [Builder.primaryAccountNumberLength] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun primaryAccountNumberLength(primaryAccountNumberLength: JsonField) = apply { + body.primaryAccountNumberLength(primaryAccountNumberLength) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardTokenCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardTokenCreateParams = + CardTokenCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val capabilities: JsonField>, + private val expiration: JsonField, + private val last4: JsonField, + private val prefix: JsonField, + private val primaryAccountNumberLength: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("capabilities") + @ExcludeMissing + capabilities: JsonField> = JsonMissing.of(), + @JsonProperty("expiration") + @ExcludeMissing + expiration: JsonField = JsonMissing.of(), + @JsonProperty("last4") @ExcludeMissing last4: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("primary_account_number_length") + @ExcludeMissing + primaryAccountNumberLength: JsonField = JsonMissing.of(), + ) : this( + capabilities, + expiration, + last4, + prefix, + primaryAccountNumberLength, + mutableMapOf(), + ) + + /** + * The capabilities of the outbound card token. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun capabilities(): Optional> = capabilities.getOptional("capabilities") + + /** + * The expiration date of the card. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiration(): Optional = expiration.getOptional("expiration") + + /** + * The last 4 digits of the card number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun last4(): Optional = last4.getOptional("last4") + + /** + * The prefix of the card number, usually the first 8 digits. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * The total length of the card number, including prefix and last4. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun primaryAccountNumberLength(): Optional = + primaryAccountNumberLength.getOptional("primary_account_number_length") + + /** + * Returns the raw JSON value of [capabilities]. + * + * Unlike [capabilities], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("capabilities") + @ExcludeMissing + fun _capabilities(): JsonField> = capabilities + + /** + * Returns the raw JSON value of [expiration]. + * + * Unlike [expiration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiration") + @ExcludeMissing + fun _expiration(): JsonField = expiration + + /** + * Returns the raw JSON value of [last4]. + * + * Unlike [last4], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last4") @ExcludeMissing fun _last4(): JsonField = last4 + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [primaryAccountNumberLength]. + * + * Unlike [primaryAccountNumberLength], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("primary_account_number_length") + @ExcludeMissing + fun _primaryAccountNumberLength(): JsonField = primaryAccountNumberLength + + @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 [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var capabilities: JsonField>? = null + private var expiration: JsonField = JsonMissing.of() + private var last4: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var primaryAccountNumberLength: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + capabilities = body.capabilities.map { it.toMutableList() } + expiration = body.expiration + last4 = body.last4 + prefix = body.prefix + primaryAccountNumberLength = body.primaryAccountNumberLength + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The capabilities of the outbound card token. */ + fun capabilities(capabilities: List) = + capabilities(JsonField.of(capabilities)) + + /** + * Sets [Builder.capabilities] to an arbitrary JSON value. + * + * You should usually call [Builder.capabilities] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun capabilities(capabilities: JsonField>) = apply { + this.capabilities = capabilities.map { it.toMutableList() } + } + + /** + * Adds a single [Capability] to [capabilities]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCapability(capability: Capability) = apply { + capabilities = + (capabilities ?: JsonField.of(mutableListOf())).also { + checkKnown("capabilities", it).add(capability) + } + } + + /** The expiration date of the card. */ + fun expiration(expiration: LocalDate) = expiration(JsonField.of(expiration)) + + /** + * Sets [Builder.expiration] to an arbitrary JSON value. + * + * You should usually call [Builder.expiration] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiration(expiration: JsonField) = apply { + this.expiration = expiration + } + + /** The last 4 digits of the card number. */ + fun last4(last4: String) = last4(JsonField.of(last4)) + + /** + * Sets [Builder.last4] to an arbitrary JSON value. + * + * You should usually call [Builder.last4] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun last4(last4: JsonField) = apply { this.last4 = last4 } + + /** The prefix of the card number, usually the first 8 digits. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** The total length of the card number, including prefix and last4. */ + fun primaryAccountNumberLength(primaryAccountNumberLength: Long) = + primaryAccountNumberLength(JsonField.of(primaryAccountNumberLength)) + + /** + * Sets [Builder.primaryAccountNumberLength] to an arbitrary JSON value. + * + * You should usually call [Builder.primaryAccountNumberLength] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun primaryAccountNumberLength(primaryAccountNumberLength: JsonField) = apply { + this.primaryAccountNumberLength = primaryAccountNumberLength + } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (capabilities ?: JsonMissing.of()).map { it.toImmutable() }, + expiration, + last4, + prefix, + primaryAccountNumberLength, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + capabilities().ifPresent { it.forEach { it.validate() } } + expiration() + last4() + prefix() + primaryAccountNumberLength() + 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 = + (capabilities.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (expiration.asKnown().isPresent) 1 else 0) + + (if (last4.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (primaryAccountNumberLength.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + capabilities == other.capabilities && + expiration == other.expiration && + last4 == other.last4 && + prefix == other.prefix && + primaryAccountNumberLength == other.primaryAccountNumberLength && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + capabilities, + expiration, + last4, + prefix, + primaryAccountNumberLength, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{capabilities=$capabilities, expiration=$expiration, last4=$last4, prefix=$prefix, primaryAccountNumberLength=$primaryAccountNumberLength, additionalProperties=$additionalProperties}" + } + + class Capability + private constructor( + private val crossBorderPushTransfers: JsonField, + private val domesticPushTransfers: JsonField, + private val route: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cross_border_push_transfers") + @ExcludeMissing + crossBorderPushTransfers: JsonField = JsonMissing.of(), + @JsonProperty("domestic_push_transfers") + @ExcludeMissing + domesticPushTransfers: JsonField = JsonMissing.of(), + @JsonProperty("route") @ExcludeMissing route: JsonField = JsonMissing.of(), + ) : this(crossBorderPushTransfers, domesticPushTransfers, route, mutableMapOf()) + + /** + * The cross-border push transfers capability. + * + * @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 crossBorderPushTransfers(): CrossBorderPushTransfers = + crossBorderPushTransfers.getRequired("cross_border_push_transfers") + + /** + * The domestic push transfers capability. + * + * @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 domesticPushTransfers(): DomesticPushTransfers = + domesticPushTransfers.getRequired("domestic_push_transfers") + + /** + * The route of the capability. + * + * @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 route(): Route = route.getRequired("route") + + /** + * Returns the raw JSON value of [crossBorderPushTransfers]. + * + * Unlike [crossBorderPushTransfers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cross_border_push_transfers") + @ExcludeMissing + fun _crossBorderPushTransfers(): JsonField = + crossBorderPushTransfers + + /** + * Returns the raw JSON value of [domesticPushTransfers]. + * + * Unlike [domesticPushTransfers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("domestic_push_transfers") + @ExcludeMissing + fun _domesticPushTransfers(): JsonField = domesticPushTransfers + + /** + * Returns the raw JSON value of [route]. + * + * Unlike [route], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("route") @ExcludeMissing fun _route(): JsonField = route + + @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 [Capability]. + * + * The following fields are required: + * ```java + * .crossBorderPushTransfers() + * .domesticPushTransfers() + * .route() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Capability]. */ + class Builder internal constructor() { + + private var crossBorderPushTransfers: JsonField? = null + private var domesticPushTransfers: JsonField? = null + private var route: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(capability: Capability) = apply { + crossBorderPushTransfers = capability.crossBorderPushTransfers + domesticPushTransfers = capability.domesticPushTransfers + route = capability.route + additionalProperties = capability.additionalProperties.toMutableMap() + } + + /** The cross-border push transfers capability. */ + fun crossBorderPushTransfers(crossBorderPushTransfers: CrossBorderPushTransfers) = + crossBorderPushTransfers(JsonField.of(crossBorderPushTransfers)) + + /** + * Sets [Builder.crossBorderPushTransfers] to an arbitrary JSON value. + * + * You should usually call [Builder.crossBorderPushTransfers] with a well-typed + * [CrossBorderPushTransfers] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun crossBorderPushTransfers( + crossBorderPushTransfers: JsonField + ) = apply { this.crossBorderPushTransfers = crossBorderPushTransfers } + + /** The domestic push transfers capability. */ + fun domesticPushTransfers(domesticPushTransfers: DomesticPushTransfers) = + domesticPushTransfers(JsonField.of(domesticPushTransfers)) + + /** + * Sets [Builder.domesticPushTransfers] to an arbitrary JSON value. + * + * You should usually call [Builder.domesticPushTransfers] with a well-typed + * [DomesticPushTransfers] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun domesticPushTransfers(domesticPushTransfers: JsonField) = + apply { + this.domesticPushTransfers = domesticPushTransfers + } + + /** The route of the capability. */ + fun route(route: Route) = route(JsonField.of(route)) + + /** + * Sets [Builder.route] to an arbitrary JSON value. + * + * You should usually call [Builder.route] with a well-typed [Route] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun route(route: JsonField) = apply { this.route = route } + + 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 [Capability]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .crossBorderPushTransfers() + * .domesticPushTransfers() + * .route() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Capability = + Capability( + checkRequired("crossBorderPushTransfers", crossBorderPushTransfers), + checkRequired("domesticPushTransfers", domesticPushTransfers), + checkRequired("route", route), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Capability = apply { + if (validated) { + return@apply + } + + crossBorderPushTransfers().validate() + domesticPushTransfers().validate() + route().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 = + (crossBorderPushTransfers.asKnown().getOrNull()?.validity() ?: 0) + + (domesticPushTransfers.asKnown().getOrNull()?.validity() ?: 0) + + (route.asKnown().getOrNull()?.validity() ?: 0) + + /** The cross-border push transfers capability. */ + class CrossBorderPushTransfers + @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 capability is supported. */ + @JvmField val SUPPORTED = of("supported") + + /** The capability is not supported. */ + @JvmField val NOT_SUPPORTED = of("not_supported") + + @JvmStatic fun of(value: String) = CrossBorderPushTransfers(JsonField.of(value)) + } + + /** An enum containing [CrossBorderPushTransfers]'s known values. */ + enum class Known { + /** The capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + } + + /** + * An enum containing [CrossBorderPushTransfers]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CrossBorderPushTransfers] 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 capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + /** + * An enum member indicating that [CrossBorderPushTransfers] 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) { + SUPPORTED -> Value.SUPPORTED + NOT_SUPPORTED -> Value.NOT_SUPPORTED + 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) { + SUPPORTED -> Known.SUPPORTED + NOT_SUPPORTED -> Known.NOT_SUPPORTED + else -> + throw IncreaseInvalidDataException( + "Unknown CrossBorderPushTransfers: $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(): CrossBorderPushTransfers = 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 CrossBorderPushTransfers && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The domestic push transfers capability. */ + class DomesticPushTransfers + @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 capability is supported. */ + @JvmField val SUPPORTED = of("supported") + + /** The capability is not supported. */ + @JvmField val NOT_SUPPORTED = of("not_supported") + + @JvmStatic fun of(value: String) = DomesticPushTransfers(JsonField.of(value)) + } + + /** An enum containing [DomesticPushTransfers]'s known values. */ + enum class Known { + /** The capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + } + + /** + * An enum containing [DomesticPushTransfers]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DomesticPushTransfers] 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 capability is supported. */ + SUPPORTED, + /** The capability is not supported. */ + NOT_SUPPORTED, + /** + * An enum member indicating that [DomesticPushTransfers] 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) { + SUPPORTED -> Value.SUPPORTED + NOT_SUPPORTED -> Value.NOT_SUPPORTED + 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) { + SUPPORTED -> Known.SUPPORTED + NOT_SUPPORTED -> Known.NOT_SUPPORTED + else -> + throw IncreaseInvalidDataException("Unknown DomesticPushTransfers: $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(): DomesticPushTransfers = 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 DomesticPushTransfers && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The route of the capability. */ + class Route @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 { + + /** Visa and Interlink */ + @JvmField val VISA = of("visa") + + /** Mastercard and Maestro */ + @JvmField val MASTERCARD = of("mastercard") + + @JvmStatic fun of(value: String) = Route(JsonField.of(value)) + } + + /** An enum containing [Route]'s known values. */ + enum class Known { + /** Visa and Interlink */ + VISA, + /** Mastercard and Maestro */ + MASTERCARD, + } + + /** + * An enum containing [Route]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Route] 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 { + /** Visa and Interlink */ + VISA, + /** Mastercard and Maestro */ + MASTERCARD, + /** + * An enum member indicating that [Route] 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) { + VISA -> Value.VISA + MASTERCARD -> Value.MASTERCARD + 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) { + VISA -> Known.VISA + MASTERCARD -> Known.MASTERCARD + else -> throw IncreaseInvalidDataException("Unknown Route: $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(): Route = 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 Route && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Capability && + crossBorderPushTransfers == other.crossBorderPushTransfers && + domesticPushTransfers == other.domesticPushTransfers && + route == other.route && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + crossBorderPushTransfers, + domesticPushTransfers, + route, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Capability{crossBorderPushTransfers=$crossBorderPushTransfers, domesticPushTransfers=$domesticPushTransfers, route=$route, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTokenCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardTokenCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardPushTransferServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardPushTransferServiceAsync.kt new file mode 100644 index 000000000..c403c059f --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardPushTransferServiceAsync.kt @@ -0,0 +1,364 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardpushtransfers.CardPushTransfer +import com.increase.api.models.cardpushtransfers.CardPushTransferApproveParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCancelParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams +import com.increase.api.models.cardpushtransfers.CardPushTransferListPageAsync +import com.increase.api.models.cardpushtransfers.CardPushTransferListParams +import com.increase.api.models.cardpushtransfers.CardPushTransferRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardPushTransferServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardPushTransferServiceAsync + + /** Create a Card Push Transfer */ + fun create(params: CardPushTransferCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieve a Card Push Transfer */ + fun retrieve(cardPushTransferId: String): CompletableFuture = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().cardPushTransferId(cardPushTransferId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + ): CompletableFuture = + retrieve(cardPushTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: CardPushTransferRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none(), requestOptions) + + /** List Card Push Transfers */ + fun list(): CompletableFuture = + list(CardPushTransferListParams.none()) + + /** @see list */ + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(CardPushTransferListParams.none(), requestOptions) + + /** Approves a Card Push Transfer in a pending_approval state. */ + fun approve(cardPushTransferId: String): CompletableFuture = + approve(cardPushTransferId, CardPushTransferApproveParams.none()) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + approve(params.toBuilder().cardPushTransferId(cardPushTransferId).build(), requestOptions) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + ): CompletableFuture = + approve(cardPushTransferId, params, RequestOptions.none()) + + /** @see approve */ + fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see approve */ + fun approve(params: CardPushTransferApproveParams): CompletableFuture = + approve(params, RequestOptions.none()) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + approve(cardPushTransferId, CardPushTransferApproveParams.none(), requestOptions) + + /** Cancels a Card Push Transfer in a pending_approval state. */ + fun cancel(cardPushTransferId: String): CompletableFuture = + cancel(cardPushTransferId, CardPushTransferCancelParams.none()) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().cardPushTransferId(cardPushTransferId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + ): CompletableFuture = + cancel(cardPushTransferId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: CardPushTransferCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(cardPushTransferId, CardPushTransferCancelParams.none(), requestOptions) + + /** + * A view of [CardPushTransferServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardPushTransferServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /card_push_transfers`, but is otherwise the same as + * [CardPushTransferServiceAsync.create]. + */ + fun create( + params: CardPushTransferCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /card_push_transfers/{card_push_transfer_id}`, but + * is otherwise the same as [CardPushTransferServiceAsync.retrieve]. + */ + fun retrieve( + cardPushTransferId: String + ): CompletableFuture> = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve( + params.toBuilder().cardPushTransferId(cardPushTransferId).build(), + requestOptions, + ) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + ): CompletableFuture> = + retrieve(cardPushTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: CardPushTransferRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_push_transfers`, but is otherwise the same as + * [CardPushTransferServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(CardPushTransferListParams.none()) + + /** @see list */ + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CardPushTransferListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /card_push_transfers/{card_push_transfer_id}/approve`, but is otherwise the same as + * [CardPushTransferServiceAsync.approve]. + */ + fun approve( + cardPushTransferId: String + ): CompletableFuture> = + approve(cardPushTransferId, CardPushTransferApproveParams.none()) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + approve( + params.toBuilder().cardPushTransferId(cardPushTransferId).build(), + requestOptions, + ) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + ): CompletableFuture> = + approve(cardPushTransferId, params, RequestOptions.none()) + + /** @see approve */ + fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see approve */ + fun approve( + params: CardPushTransferApproveParams + ): CompletableFuture> = + approve(params, RequestOptions.none()) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + approve(cardPushTransferId, CardPushTransferApproveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /card_push_transfers/{card_push_transfer_id}/cancel`, but is otherwise the same as + * [CardPushTransferServiceAsync.cancel]. + */ + fun cancel( + cardPushTransferId: String + ): CompletableFuture> = + cancel(cardPushTransferId, CardPushTransferCancelParams.none()) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel( + params.toBuilder().cardPushTransferId(cardPushTransferId).build(), + requestOptions, + ) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + ): CompletableFuture> = + cancel(cardPushTransferId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: CardPushTransferCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(cardPushTransferId, CardPushTransferCancelParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardPushTransferServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardPushTransferServiceAsyncImpl.kt new file mode 100644 index 000000000..96ac722c2 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardPushTransferServiceAsyncImpl.kt @@ -0,0 +1,263 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.cardpushtransfers.CardPushTransfer +import com.increase.api.models.cardpushtransfers.CardPushTransferApproveParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCancelParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams +import com.increase.api.models.cardpushtransfers.CardPushTransferListPageAsync +import com.increase.api.models.cardpushtransfers.CardPushTransferListPageResponse +import com.increase.api.models.cardpushtransfers.CardPushTransferListParams +import com.increase.api.models.cardpushtransfers.CardPushTransferRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardPushTransferServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : CardPushTransferServiceAsync { + + private val withRawResponse: CardPushTransferServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardPushTransferServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): CardPushTransferServiceAsync = + CardPushTransferServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_push_transfers + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_push_transfers/{card_push_transfer_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CardPushTransferListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_push_transfers + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_push_transfers/{card_push_transfer_id}/approve + withRawResponse().approve(params, requestOptions).thenApply { it.parse() } + + override fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_push_transfers/{card_push_transfer_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardPushTransferServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardPushTransferServiceAsync.WithRawResponse = + CardPushTransferServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPushTransferId", params.cardPushTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardPushTransferListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardPushTransferListPageAsync.builder() + .service(CardPushTransferServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val approveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPushTransferId", params.cardPushTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers", params._pathParam(0), "approve") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { approveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPushTransferId", params.cardPushTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardTokenServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardTokenServiceAsync.kt new file mode 100644 index 000000000..0f575bd74 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardTokenServiceAsync.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.cardtokens.CardTokenCapabilities +import com.increase.api.models.cardtokens.CardTokenCapabilitiesParams +import com.increase.api.models.cardtokens.CardTokenListPageAsync +import com.increase.api.models.cardtokens.CardTokenListParams +import com.increase.api.models.cardtokens.CardTokenRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardTokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardTokenServiceAsync + + /** Retrieve a Card Token */ + fun retrieve(cardTokenId: String): CompletableFuture = + retrieve(cardTokenId, CardTokenRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + ): CompletableFuture = retrieve(cardTokenId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: CardTokenRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(cardTokenId, CardTokenRetrieveParams.none(), requestOptions) + + /** List Card Tokens */ + fun list(): CompletableFuture = list(CardTokenListParams.none()) + + /** @see list */ + fun list( + params: CardTokenListParams = CardTokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: CardTokenListParams = CardTokenListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(CardTokenListParams.none(), requestOptions) + + /** + * The capabilities of a Card Token describe whether the card can be used for specific + * operations, such as Card Push Transfers. The capabilities can change over time based on the + * issuing bank's configuration of the card range. + */ + fun capabilities(cardTokenId: String): CompletableFuture = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none()) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + capabilities(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + ): CompletableFuture = + capabilities(cardTokenId, params, RequestOptions.none()) + + /** @see capabilities */ + fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see capabilities */ + fun capabilities( + params: CardTokenCapabilitiesParams + ): CompletableFuture = capabilities(params, RequestOptions.none()) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none(), requestOptions) + + /** + * A view of [CardTokenServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /card_tokens/{card_token_id}`, but is otherwise the + * same as [CardTokenServiceAsync.retrieve]. + */ + fun retrieve(cardTokenId: String): CompletableFuture> = + retrieve(cardTokenId, CardTokenRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + ): CompletableFuture> = + retrieve(cardTokenId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: CardTokenRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(cardTokenId, CardTokenRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_tokens`, but is otherwise the same as + * [CardTokenServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(CardTokenListParams.none()) + + /** @see list */ + fun list( + params: CardTokenListParams = CardTokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: CardTokenListParams = CardTokenListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CardTokenListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_tokens/{card_token_id}/capabilities`, but is + * otherwise the same as [CardTokenServiceAsync.capabilities]. + */ + fun capabilities( + cardTokenId: String + ): CompletableFuture> = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none()) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + capabilities(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + ): CompletableFuture> = + capabilities(cardTokenId, params, RequestOptions.none()) + + /** @see capabilities */ + fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see capabilities */ + fun capabilities( + params: CardTokenCapabilitiesParams + ): CompletableFuture> = + capabilities(params, RequestOptions.none()) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardTokenServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardTokenServiceAsyncImpl.kt new file mode 100644 index 000000000..4d23b37f2 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardTokenServiceAsyncImpl.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.cardtokens.CardTokenCapabilities +import com.increase.api.models.cardtokens.CardTokenCapabilitiesParams +import com.increase.api.models.cardtokens.CardTokenListPageAsync +import com.increase.api.models.cardtokens.CardTokenListPageResponse +import com.increase.api.models.cardtokens.CardTokenListParams +import com.increase.api.models.cardtokens.CardTokenRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenServiceAsync { + + private val withRawResponse: CardTokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardTokenServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardTokenServiceAsync = + CardTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_tokens/{card_token_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CardTokenListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_tokens + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_tokens/{card_token_id}/capabilities + withRawResponse().capabilities(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardTokenServiceAsync.WithRawResponse = + CardTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardTokenId", params.cardTokenId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_tokens", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardTokenListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_tokens") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardTokenListPageAsync.builder() + .service(CardTokenServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val capabilitiesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardTokenId", params.cardTokenId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_tokens", params._pathParam(0), "capabilities") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { capabilitiesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardValidationServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardValidationServiceAsync.kt new file mode 100644 index 000000000..5e203d626 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardValidationServiceAsync.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardvalidations.CardValidation +import com.increase.api.models.cardvalidations.CardValidationCreateParams +import com.increase.api.models.cardvalidations.CardValidationListPageAsync +import com.increase.api.models.cardvalidations.CardValidationListParams +import com.increase.api.models.cardvalidations.CardValidationRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardValidationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardValidationServiceAsync + + /** Create a Card Validation */ + fun create(params: CardValidationCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieve a Card Validation */ + fun retrieve(cardValidationId: String): CompletableFuture = + retrieve(cardValidationId, CardValidationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().cardValidationId(cardValidationId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + ): CompletableFuture = retrieve(cardValidationId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: CardValidationRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(cardValidationId, CardValidationRetrieveParams.none(), requestOptions) + + /** List Card Validations */ + fun list(): CompletableFuture = + list(CardValidationListParams.none()) + + /** @see list */ + fun list( + params: CardValidationListParams = CardValidationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: CardValidationListParams = CardValidationListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(CardValidationListParams.none(), requestOptions) + + /** + * A view of [CardValidationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardValidationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /card_validations`, but is otherwise the same as + * [CardValidationServiceAsync.create]. + */ + fun create( + params: CardValidationCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /card_validations/{card_validation_id}`, but is + * otherwise the same as [CardValidationServiceAsync.retrieve]. + */ + fun retrieve(cardValidationId: String): CompletableFuture> = + retrieve(cardValidationId, CardValidationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().cardValidationId(cardValidationId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + ): CompletableFuture> = + retrieve(cardValidationId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: CardValidationRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(cardValidationId, CardValidationRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_validations`, but is otherwise the same as + * [CardValidationServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(CardValidationListParams.none()) + + /** @see list */ + fun list( + params: CardValidationListParams = CardValidationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: CardValidationListParams = CardValidationListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CardValidationListParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardValidationServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardValidationServiceAsyncImpl.kt new file mode 100644 index 000000000..2e217097b --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardValidationServiceAsyncImpl.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.cardvalidations.CardValidation +import com.increase.api.models.cardvalidations.CardValidationCreateParams +import com.increase.api.models.cardvalidations.CardValidationListPageAsync +import com.increase.api.models.cardvalidations.CardValidationListPageResponse +import com.increase.api.models.cardvalidations.CardValidationListParams +import com.increase.api.models.cardvalidations.CardValidationRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardValidationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : CardValidationServiceAsync { + + private val withRawResponse: CardValidationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardValidationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): CardValidationServiceAsync = + CardValidationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_validations + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_validations/{card_validation_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CardValidationListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_validations + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardValidationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardValidationServiceAsync.WithRawResponse = + CardValidationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_validations") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardValidationId", params.cardValidationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_validations", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardValidationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_validations") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardValidationListPageAsync.builder() + .service(CardValidationServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt index 3625238b8..b59f3d6ea 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt @@ -14,6 +14,7 @@ import com.increase.api.services.async.simulations.CardIncrementServiceAsync import com.increase.api.services.async.simulations.CardRefundServiceAsync import com.increase.api.services.async.simulations.CardReversalServiceAsync import com.increase.api.services.async.simulations.CardSettlementServiceAsync +import com.increase.api.services.async.simulations.CardTokenServiceAsync import com.increase.api.services.async.simulations.CheckDepositServiceAsync import com.increase.api.services.async.simulations.CheckTransferServiceAsync import com.increase.api.services.async.simulations.DigitalWalletTokenRequestServiceAsync @@ -103,6 +104,8 @@ interface SimulationServiceAsync { fun documents(): DocumentServiceAsync + fun cardTokens(): CardTokenServiceAsync + /** * A view of [SimulationServiceAsync] that provides access to raw HTTP responses for each * method. @@ -174,5 +177,7 @@ interface SimulationServiceAsync { fun accountStatements(): AccountStatementServiceAsync.WithRawResponse fun documents(): DocumentServiceAsync.WithRawResponse + + fun cardTokens(): CardTokenServiceAsync.WithRawResponse } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt index 162d2812d..b641f550b 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt @@ -25,6 +25,8 @@ import com.increase.api.services.async.simulations.CardReversalServiceAsync import com.increase.api.services.async.simulations.CardReversalServiceAsyncImpl import com.increase.api.services.async.simulations.CardSettlementServiceAsync import com.increase.api.services.async.simulations.CardSettlementServiceAsyncImpl +import com.increase.api.services.async.simulations.CardTokenServiceAsync +import com.increase.api.services.async.simulations.CardTokenServiceAsyncImpl import com.increase.api.services.async.simulations.CheckDepositServiceAsync import com.increase.api.services.async.simulations.CheckDepositServiceAsyncImpl import com.increase.api.services.async.simulations.CheckTransferServiceAsync @@ -177,6 +179,10 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: private val documents: DocumentServiceAsync by lazy { DocumentServiceAsyncImpl(clientOptions) } + private val cardTokens: CardTokenServiceAsync by lazy { + CardTokenServiceAsyncImpl(clientOptions) + } + override fun withRawResponse(): SimulationServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): SimulationServiceAsync = @@ -243,6 +249,8 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: override fun documents(): DocumentServiceAsync = documents + override fun cardTokens(): CardTokenServiceAsync = cardTokens + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SimulationServiceAsync.WithRawResponse { @@ -364,6 +372,10 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: DocumentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardTokens: CardTokenServiceAsync.WithRawResponse by lazy { + CardTokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): SimulationServiceAsync.WithRawResponse = @@ -443,5 +455,7 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: accountStatements override fun documents(): DocumentServiceAsync.WithRawResponse = documents + + override fun cardTokens(): CardTokenServiceAsync.WithRawResponse = cardTokens } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsync.kt new file mode 100644 index 000000000..0d7097cc1 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsync.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.simulations.cardtokens.CardTokenCreateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardTokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardTokenServiceAsync + + /** Simulates tokenizing a card in the sandbox environment. */ + fun create(): CompletableFuture = create(CardTokenCreateParams.none()) + + /** @see create */ + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none() + ): CompletableFuture = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture = + create(CardTokenCreateParams.none(), requestOptions) + + /** + * A view of [CardTokenServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /simulations/card_tokens`, but is otherwise the + * same as [CardTokenServiceAsync.create]. + */ + fun create(): CompletableFuture> = + create(CardTokenCreateParams.none()) + + /** @see create */ + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none() + ): CompletableFuture> = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture> = + create(CardTokenCreateParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsyncImpl.kt new file mode 100644 index 000000000..c57acf01d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.simulations.cardtokens.CardTokenCreateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class CardTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenServiceAsync { + + private val withRawResponse: CardTokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardTokenServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardTokenServiceAsync = + CardTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardTokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /simulations/card_tokens + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardTokenServiceAsync.WithRawResponse = + CardTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardTokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("simulations", "card_tokens") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardPushTransferService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardPushTransferService.kt new file mode 100644 index 000000000..8f616591d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardPushTransferService.kt @@ -0,0 +1,358 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardpushtransfers.CardPushTransfer +import com.increase.api.models.cardpushtransfers.CardPushTransferApproveParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCancelParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams +import com.increase.api.models.cardpushtransfers.CardPushTransferListPage +import com.increase.api.models.cardpushtransfers.CardPushTransferListParams +import com.increase.api.models.cardpushtransfers.CardPushTransferRetrieveParams +import java.util.function.Consumer + +interface CardPushTransferService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardPushTransferService + + /** Create a Card Push Transfer */ + fun create(params: CardPushTransferCreateParams): CardPushTransfer = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer + + /** Retrieve a Card Push Transfer */ + fun retrieve(cardPushTransferId: String): CardPushTransfer = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer = + retrieve(params.toBuilder().cardPushTransferId(cardPushTransferId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + ): CardPushTransfer = retrieve(cardPushTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer + + /** @see retrieve */ + fun retrieve(params: CardPushTransferRetrieveParams): CardPushTransfer = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(cardPushTransferId: String, requestOptions: RequestOptions): CardPushTransfer = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none(), requestOptions) + + /** List Card Push Transfers */ + fun list(): CardPushTransferListPage = list(CardPushTransferListParams.none()) + + /** @see list */ + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransferListPage + + /** @see list */ + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none() + ): CardPushTransferListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CardPushTransferListPage = + list(CardPushTransferListParams.none(), requestOptions) + + /** Approves a Card Push Transfer in a pending_approval state. */ + fun approve(cardPushTransferId: String): CardPushTransfer = + approve(cardPushTransferId, CardPushTransferApproveParams.none()) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer = + approve(params.toBuilder().cardPushTransferId(cardPushTransferId).build(), requestOptions) + + /** @see approve */ + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + ): CardPushTransfer = approve(cardPushTransferId, params, RequestOptions.none()) + + /** @see approve */ + fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer + + /** @see approve */ + fun approve(params: CardPushTransferApproveParams): CardPushTransfer = + approve(params, RequestOptions.none()) + + /** @see approve */ + fun approve(cardPushTransferId: String, requestOptions: RequestOptions): CardPushTransfer = + approve(cardPushTransferId, CardPushTransferApproveParams.none(), requestOptions) + + /** Cancels a Card Push Transfer in a pending_approval state. */ + fun cancel(cardPushTransferId: String): CardPushTransfer = + cancel(cardPushTransferId, CardPushTransferCancelParams.none()) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer = + cancel(params.toBuilder().cardPushTransferId(cardPushTransferId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + ): CardPushTransfer = cancel(cardPushTransferId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPushTransfer + + /** @see cancel */ + fun cancel(params: CardPushTransferCancelParams): CardPushTransfer = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(cardPushTransferId: String, requestOptions: RequestOptions): CardPushTransfer = + cancel(cardPushTransferId, CardPushTransferCancelParams.none(), requestOptions) + + /** + * A view of [CardPushTransferService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardPushTransferService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /card_push_transfers`, but is otherwise the same as + * [CardPushTransferService.create]. + */ + @MustBeClosed + fun create(params: CardPushTransferCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /card_push_transfers/{card_push_transfer_id}`, but + * is otherwise the same as [CardPushTransferService.retrieve]. + */ + @MustBeClosed + fun retrieve(cardPushTransferId: String): HttpResponseFor = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve( + params.toBuilder().cardPushTransferId(cardPushTransferId).build(), + requestOptions, + ) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardPushTransferId: String, + params: CardPushTransferRetrieveParams = CardPushTransferRetrieveParams.none(), + ): HttpResponseFor = + retrieve(cardPushTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CardPushTransferRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(cardPushTransferId, CardPushTransferRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_push_transfers`, but is otherwise the same as + * [CardPushTransferService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = + list(CardPushTransferListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: CardPushTransferListParams = CardPushTransferListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CardPushTransferListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /card_push_transfers/{card_push_transfer_id}/approve`, but is otherwise the same as + * [CardPushTransferService.approve]. + */ + @MustBeClosed + fun approve(cardPushTransferId: String): HttpResponseFor = + approve(cardPushTransferId, CardPushTransferApproveParams.none()) + + /** @see approve */ + @MustBeClosed + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + approve( + params.toBuilder().cardPushTransferId(cardPushTransferId).build(), + requestOptions, + ) + + /** @see approve */ + @MustBeClosed + fun approve( + cardPushTransferId: String, + params: CardPushTransferApproveParams = CardPushTransferApproveParams.none(), + ): HttpResponseFor = + approve(cardPushTransferId, params, RequestOptions.none()) + + /** @see approve */ + @MustBeClosed + fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see approve */ + @MustBeClosed + fun approve(params: CardPushTransferApproveParams): HttpResponseFor = + approve(params, RequestOptions.none()) + + /** @see approve */ + @MustBeClosed + fun approve( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + approve(cardPushTransferId, CardPushTransferApproveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /card_push_transfers/{card_push_transfer_id}/cancel`, but is otherwise the same as + * [CardPushTransferService.cancel]. + */ + @MustBeClosed + fun cancel(cardPushTransferId: String): HttpResponseFor = + cancel(cardPushTransferId, CardPushTransferCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel( + params.toBuilder().cardPushTransferId(cardPushTransferId).build(), + requestOptions, + ) + + /** @see cancel */ + @MustBeClosed + fun cancel( + cardPushTransferId: String, + params: CardPushTransferCancelParams = CardPushTransferCancelParams.none(), + ): HttpResponseFor = + cancel(cardPushTransferId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: CardPushTransferCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + cardPushTransferId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(cardPushTransferId, CardPushTransferCancelParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardPushTransferServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardPushTransferServiceImpl.kt new file mode 100644 index 000000000..ea2025b6a --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardPushTransferServiceImpl.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.cardpushtransfers.CardPushTransfer +import com.increase.api.models.cardpushtransfers.CardPushTransferApproveParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCancelParams +import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams +import com.increase.api.models.cardpushtransfers.CardPushTransferListPage +import com.increase.api.models.cardpushtransfers.CardPushTransferListPageResponse +import com.increase.api.models.cardpushtransfers.CardPushTransferListParams +import com.increase.api.models.cardpushtransfers.CardPushTransferRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardPushTransferServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardPushTransferService { + + private val withRawResponse: CardPushTransferService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardPushTransferService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardPushTransferService = + CardPushTransferServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions, + ): CardPushTransfer = + // post /card_push_transfers + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions, + ): CardPushTransfer = + // get /card_push_transfers/{card_push_transfer_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: CardPushTransferListParams, + requestOptions: RequestOptions, + ): CardPushTransferListPage = + // get /card_push_transfers + withRawResponse().list(params, requestOptions).parse() + + override fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions, + ): CardPushTransfer = + // post /card_push_transfers/{card_push_transfer_id}/approve + withRawResponse().approve(params, requestOptions).parse() + + override fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions, + ): CardPushTransfer = + // post /card_push_transfers/{card_push_transfer_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardPushTransferService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardPushTransferService.WithRawResponse = + CardPushTransferServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardPushTransferCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardPushTransferRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPushTransferId", params.cardPushTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardPushTransferListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardPushTransferListPage.builder() + .service(CardPushTransferServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val approveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun approve( + params: CardPushTransferApproveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPushTransferId", params.cardPushTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers", params._pathParam(0), "approve") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { approveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: CardPushTransferCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPushTransferId", params.cardPushTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_push_transfers", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardTokenService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardTokenService.kt new file mode 100644 index 000000000..8ed7df58d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardTokenService.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.cardtokens.CardTokenCapabilities +import com.increase.api.models.cardtokens.CardTokenCapabilitiesParams +import com.increase.api.models.cardtokens.CardTokenListPage +import com.increase.api.models.cardtokens.CardTokenListParams +import com.increase.api.models.cardtokens.CardTokenRetrieveParams +import java.util.function.Consumer + +interface CardTokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardTokenService + + /** Retrieve a Card Token */ + fun retrieve(cardTokenId: String): CardToken = + retrieve(cardTokenId, CardTokenRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardToken = retrieve(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + ): CardToken = retrieve(cardTokenId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardToken + + /** @see retrieve */ + fun retrieve(params: CardTokenRetrieveParams): CardToken = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(cardTokenId: String, requestOptions: RequestOptions): CardToken = + retrieve(cardTokenId, CardTokenRetrieveParams.none(), requestOptions) + + /** List Card Tokens */ + fun list(): CardTokenListPage = list(CardTokenListParams.none()) + + /** @see list */ + fun list( + params: CardTokenListParams = CardTokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardTokenListPage + + /** @see list */ + fun list(params: CardTokenListParams = CardTokenListParams.none()): CardTokenListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CardTokenListPage = + list(CardTokenListParams.none(), requestOptions) + + /** + * The capabilities of a Card Token describe whether the card can be used for specific + * operations, such as Card Push Transfers. The capabilities can change over time based on the + * issuing bank's configuration of the card range. + */ + fun capabilities(cardTokenId: String): CardTokenCapabilities = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none()) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardTokenCapabilities = + capabilities(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see capabilities */ + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + ): CardTokenCapabilities = capabilities(cardTokenId, params, RequestOptions.none()) + + /** @see capabilities */ + fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardTokenCapabilities + + /** @see capabilities */ + fun capabilities(params: CardTokenCapabilitiesParams): CardTokenCapabilities = + capabilities(params, RequestOptions.none()) + + /** @see capabilities */ + fun capabilities(cardTokenId: String, requestOptions: RequestOptions): CardTokenCapabilities = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none(), requestOptions) + + /** A view of [CardTokenService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /card_tokens/{card_token_id}`, but is otherwise the + * same as [CardTokenService.retrieve]. + */ + @MustBeClosed + fun retrieve(cardTokenId: String): HttpResponseFor = + retrieve(cardTokenId, CardTokenRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardTokenId: String, + params: CardTokenRetrieveParams = CardTokenRetrieveParams.none(), + ): HttpResponseFor = retrieve(cardTokenId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CardTokenRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardTokenId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(cardTokenId, CardTokenRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_tokens`, but is otherwise the same as + * [CardTokenService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(CardTokenListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CardTokenListParams = CardTokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: CardTokenListParams = CardTokenListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CardTokenListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_tokens/{card_token_id}/capabilities`, but is + * otherwise the same as [CardTokenService.capabilities]. + */ + @MustBeClosed + fun capabilities(cardTokenId: String): HttpResponseFor = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none()) + + /** @see capabilities */ + @MustBeClosed + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + capabilities(params.toBuilder().cardTokenId(cardTokenId).build(), requestOptions) + + /** @see capabilities */ + @MustBeClosed + fun capabilities( + cardTokenId: String, + params: CardTokenCapabilitiesParams = CardTokenCapabilitiesParams.none(), + ): HttpResponseFor = + capabilities(cardTokenId, params, RequestOptions.none()) + + /** @see capabilities */ + @MustBeClosed + fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see capabilities */ + @MustBeClosed + fun capabilities( + params: CardTokenCapabilitiesParams + ): HttpResponseFor = capabilities(params, RequestOptions.none()) + + /** @see capabilities */ + @MustBeClosed + fun capabilities( + cardTokenId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + capabilities(cardTokenId, CardTokenCapabilitiesParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardTokenServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardTokenServiceImpl.kt new file mode 100644 index 000000000..09bc5b07f --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardTokenServiceImpl.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.cardtokens.CardTokenCapabilities +import com.increase.api.models.cardtokens.CardTokenCapabilitiesParams +import com.increase.api.models.cardtokens.CardTokenListPage +import com.increase.api.models.cardtokens.CardTokenListPageResponse +import com.increase.api.models.cardtokens.CardTokenListParams +import com.increase.api.models.cardtokens.CardTokenRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenService { + + private val withRawResponse: CardTokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardTokenService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardTokenService = + CardTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions, + ): CardToken = + // get /card_tokens/{card_token_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: CardTokenListParams, + requestOptions: RequestOptions, + ): CardTokenListPage = + // get /card_tokens + withRawResponse().list(params, requestOptions).parse() + + override fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions, + ): CardTokenCapabilities = + // get /card_tokens/{card_token_id}/capabilities + withRawResponse().capabilities(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardTokenService.WithRawResponse = + CardTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardTokenRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardTokenId", params.cardTokenId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_tokens", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardTokenListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_tokens") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardTokenListPage.builder() + .service(CardTokenServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val capabilitiesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun capabilities( + params: CardTokenCapabilitiesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardTokenId", params.cardTokenId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_tokens", params._pathParam(0), "capabilities") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { capabilitiesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardValidationService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardValidationService.kt new file mode 100644 index 000000000..45388c39b --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardValidationService.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardvalidations.CardValidation +import com.increase.api.models.cardvalidations.CardValidationCreateParams +import com.increase.api.models.cardvalidations.CardValidationListPage +import com.increase.api.models.cardvalidations.CardValidationListParams +import com.increase.api.models.cardvalidations.CardValidationRetrieveParams +import java.util.function.Consumer + +interface CardValidationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardValidationService + + /** Create a Card Validation */ + fun create(params: CardValidationCreateParams): CardValidation = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardValidation + + /** Retrieve a Card Validation */ + fun retrieve(cardValidationId: String): CardValidation = + retrieve(cardValidationId, CardValidationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardValidation = + retrieve(params.toBuilder().cardValidationId(cardValidationId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + ): CardValidation = retrieve(cardValidationId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardValidation + + /** @see retrieve */ + fun retrieve(params: CardValidationRetrieveParams): CardValidation = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(cardValidationId: String, requestOptions: RequestOptions): CardValidation = + retrieve(cardValidationId, CardValidationRetrieveParams.none(), requestOptions) + + /** List Card Validations */ + fun list(): CardValidationListPage = list(CardValidationListParams.none()) + + /** @see list */ + fun list( + params: CardValidationListParams = CardValidationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardValidationListPage + + /** @see list */ + fun list( + params: CardValidationListParams = CardValidationListParams.none() + ): CardValidationListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CardValidationListPage = + list(CardValidationListParams.none(), requestOptions) + + /** + * A view of [CardValidationService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardValidationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /card_validations`, but is otherwise the same as + * [CardValidationService.create]. + */ + @MustBeClosed + fun create(params: CardValidationCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /card_validations/{card_validation_id}`, but is + * otherwise the same as [CardValidationService.retrieve]. + */ + @MustBeClosed + fun retrieve(cardValidationId: String): HttpResponseFor = + retrieve(cardValidationId, CardValidationRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().cardValidationId(cardValidationId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardValidationId: String, + params: CardValidationRetrieveParams = CardValidationRetrieveParams.none(), + ): HttpResponseFor = + retrieve(cardValidationId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CardValidationRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardValidationId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(cardValidationId, CardValidationRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_validations`, but is otherwise the same as + * [CardValidationService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(CardValidationListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CardValidationListParams = CardValidationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: CardValidationListParams = CardValidationListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CardValidationListParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardValidationServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardValidationServiceImpl.kt new file mode 100644 index 000000000..8e60fc198 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardValidationServiceImpl.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.cardvalidations.CardValidation +import com.increase.api.models.cardvalidations.CardValidationCreateParams +import com.increase.api.models.cardvalidations.CardValidationListPage +import com.increase.api.models.cardvalidations.CardValidationListPageResponse +import com.increase.api.models.cardvalidations.CardValidationListParams +import com.increase.api.models.cardvalidations.CardValidationRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardValidationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardValidationService { + + private val withRawResponse: CardValidationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardValidationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardValidationService = + CardValidationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions, + ): CardValidation = + // post /card_validations + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions, + ): CardValidation = + // get /card_validations/{card_validation_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: CardValidationListParams, + requestOptions: RequestOptions, + ): CardValidationListPage = + // get /card_validations + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardValidationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardValidationService.WithRawResponse = + CardValidationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardValidationCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_validations") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardValidationRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardValidationId", params.cardValidationId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_validations", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardValidationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_validations") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardValidationListPage.builder() + .service(CardValidationServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt index c9d6e82fe..6aa15a4c8 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt @@ -14,6 +14,7 @@ import com.increase.api.services.blocking.simulations.CardIncrementService import com.increase.api.services.blocking.simulations.CardRefundService import com.increase.api.services.blocking.simulations.CardReversalService import com.increase.api.services.blocking.simulations.CardSettlementService +import com.increase.api.services.blocking.simulations.CardTokenService import com.increase.api.services.blocking.simulations.CheckDepositService import com.increase.api.services.blocking.simulations.CheckTransferService import com.increase.api.services.blocking.simulations.DigitalWalletTokenRequestService @@ -103,6 +104,8 @@ interface SimulationService { fun documents(): DocumentService + fun cardTokens(): CardTokenService + /** A view of [SimulationService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -171,5 +174,7 @@ interface SimulationService { fun accountStatements(): AccountStatementService.WithRawResponse fun documents(): DocumentService.WithRawResponse + + fun cardTokens(): CardTokenService.WithRawResponse } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt index d954b81ba..3306bb0d7 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt @@ -25,6 +25,8 @@ import com.increase.api.services.blocking.simulations.CardReversalService import com.increase.api.services.blocking.simulations.CardReversalServiceImpl import com.increase.api.services.blocking.simulations.CardSettlementService import com.increase.api.services.blocking.simulations.CardSettlementServiceImpl +import com.increase.api.services.blocking.simulations.CardTokenService +import com.increase.api.services.blocking.simulations.CardTokenServiceImpl import com.increase.api.services.blocking.simulations.CheckDepositService import com.increase.api.services.blocking.simulations.CheckDepositServiceImpl import com.increase.api.services.blocking.simulations.CheckTransferService @@ -170,6 +172,8 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie private val documents: DocumentService by lazy { DocumentServiceImpl(clientOptions) } + private val cardTokens: CardTokenService by lazy { CardTokenServiceImpl(clientOptions) } + override fun withRawResponse(): SimulationService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): SimulationService = @@ -236,6 +240,8 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie override fun documents(): DocumentService = documents + override fun cardTokens(): CardTokenService = cardTokens + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SimulationService.WithRawResponse { @@ -356,6 +362,10 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie DocumentServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardTokens: CardTokenService.WithRawResponse by lazy { + CardTokenServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): SimulationService.WithRawResponse = @@ -432,5 +442,7 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie accountStatements override fun documents(): DocumentService.WithRawResponse = documents + + override fun cardTokens(): CardTokenService.WithRawResponse = cardTokens } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardTokenService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardTokenService.kt new file mode 100644 index 000000000..fabac52dd --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardTokenService.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.simulations.cardtokens.CardTokenCreateParams +import java.util.function.Consumer + +interface CardTokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardTokenService + + /** Simulates tokenizing a card in the sandbox environment. */ + fun create(): CardToken = create(CardTokenCreateParams.none()) + + /** @see create */ + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardToken + + /** @see create */ + fun create(params: CardTokenCreateParams = CardTokenCreateParams.none()): CardToken = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CardToken = + create(CardTokenCreateParams.none(), requestOptions) + + /** A view of [CardTokenService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /simulations/card_tokens`, but is otherwise the + * same as [CardTokenService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor = create(CardTokenCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + params: CardTokenCreateParams = CardTokenCreateParams.none() + ): HttpResponseFor = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor = + create(CardTokenCreateParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardTokenServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardTokenServiceImpl.kt new file mode 100644 index 000000000..b49735d53 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardTokenServiceImpl.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.cardtokens.CardToken +import com.increase.api.models.simulations.cardtokens.CardTokenCreateParams +import java.util.function.Consumer + +class CardTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenService { + + private val withRawResponse: CardTokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardTokenService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardTokenService = + CardTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: CardTokenCreateParams, requestOptions: RequestOptions): CardToken = + // post /simulations/card_tokens + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardTokenService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardTokenService.WithRawResponse = + CardTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardTokenCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("simulations", "card_tokens") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferApproveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferApproveParamsTest.kt new file mode 100644 index 000000000..cc8649725 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferApproveParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferApproveParamsTest { + + @Test + fun create() { + CardPushTransferApproveParams.builder() + .cardPushTransferId("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .build() + } + + @Test + fun pathParams() { + val params = + CardPushTransferApproveParams.builder() + .cardPushTransferId("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .build() + + assertThat(params._pathParam(0)) + .isEqualTo("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCancelParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCancelParamsTest.kt new file mode 100644 index 000000000..df5c52c52 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCancelParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferCancelParamsTest { + + @Test + fun create() { + CardPushTransferCancelParams.builder() + .cardPushTransferId("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .build() + } + + @Test + fun pathParams() { + val params = + CardPushTransferCancelParams.builder() + .cardPushTransferId("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .build() + + assertThat(params._pathParam(0)) + .isEqualTo("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCreateParamsTest.kt new file mode 100644 index 000000000..c73cb4385 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferCreateParamsTest.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferCreateParamsTest { + + @Test + fun create() { + CardPushTransferCreateParams.builder() + .amount(100L) + .businessApplicationIdentifier( + CardPushTransferCreateParams.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .requireApproval(true) + .build() + } + + @Test + fun body() { + val params = + CardPushTransferCreateParams.builder() + .amount(100L) + .businessApplicationIdentifier( + CardPushTransferCreateParams.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .requireApproval(true) + .build() + + val body = params._body() + + assertThat(body.amount()).isEqualTo(100L) + assertThat(body.businessApplicationIdentifier()) + .isEqualTo( + CardPushTransferCreateParams.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + assertThat(body.cardTokenId()).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + assertThat(body.merchantCategoryCode()).isEqualTo("1234") + assertThat(body.merchantCityName()).isEqualTo("New York") + assertThat(body.merchantName()).isEqualTo("Acme Corp") + assertThat(body.merchantNamePrefix()).isEqualTo("Acme") + assertThat(body.merchantPostalCode()).isEqualTo("10045") + assertThat(body.merchantState()).isEqualTo("NY") + assertThat(body.recipientName()).isEqualTo("Ian Crease") + assertThat(body.senderAddressCity()).isEqualTo("New York") + assertThat(body.senderAddressLine1()).isEqualTo("33 Liberty Street") + assertThat(body.senderAddressPostalCode()).isEqualTo("10045") + assertThat(body.senderAddressState()).isEqualTo("NY") + assertThat(body.senderName()).isEqualTo("Ian Crease") + assertThat(body.sourceAccountNumberId()).isEqualTo("account_number_v18nkfqm6afpsrvy82b2") + assertThat(body.requireApproval()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CardPushTransferCreateParams.builder() + .amount(100L) + .businessApplicationIdentifier( + CardPushTransferCreateParams.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .build() + + val body = params._body() + + assertThat(body.amount()).isEqualTo(100L) + assertThat(body.businessApplicationIdentifier()) + .isEqualTo( + CardPushTransferCreateParams.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + assertThat(body.cardTokenId()).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + assertThat(body.merchantCategoryCode()).isEqualTo("1234") + assertThat(body.merchantCityName()).isEqualTo("New York") + assertThat(body.merchantName()).isEqualTo("Acme Corp") + assertThat(body.merchantNamePrefix()).isEqualTo("Acme") + assertThat(body.merchantPostalCode()).isEqualTo("10045") + assertThat(body.merchantState()).isEqualTo("NY") + assertThat(body.recipientName()).isEqualTo("Ian Crease") + assertThat(body.senderAddressCity()).isEqualTo("New York") + assertThat(body.senderAddressLine1()).isEqualTo("33 Liberty Street") + assertThat(body.senderAddressPostalCode()).isEqualTo("10045") + assertThat(body.senderAddressState()).isEqualTo("NY") + assertThat(body.senderName()).isEqualTo("Ian Crease") + assertThat(body.sourceAccountNumberId()).isEqualTo("account_number_v18nkfqm6afpsrvy82b2") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageResponseTest.kt new file mode 100644 index 000000000..693ed4ed6 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListPageResponseTest.kt @@ -0,0 +1,302 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferListPageResponseTest { + + @Test + fun create() { + val cardPushTransferListPageResponse = + CardPushTransferListPageResponse.builder() + .addData( + CardPushTransfer.builder() + .id("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .acceptance( + CardPushTransfer.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .authorizationIdentificationResponse( + "authorization_identification_response" + ) + .cardVerificationValue2Result( + CardPushTransfer.Acceptance.CardVerificationValue2Result.MATCH + ) + .networkTransactionIdentifier("network_transaction_identifier") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .amount(100L) + .approval( + CardPushTransfer.Approval.builder() + .approvedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .approvedBy("approved_by") + .build() + ) + .businessApplicationIdentifier( + CardPushTransfer.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cancellation( + CardPushTransfer.Cancellation.builder() + .canceledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .canceledBy("canceled_by") + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardPushTransfer.CreatedBy.builder() + .apiKey( + CardPushTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardPushTransfer.CreatedBy.Category.USER) + .oauthApplication( + CardPushTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardPushTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .currency(CardPushTransfer.Currency.USD) + .decline( + CardPushTransfer.Decline.builder() + .declinedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkTransactionIdentifier("network_transaction_identifier") + .reason(CardPushTransfer.Decline.Reason.DO_NOT_HONOR) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(CardPushTransfer.Status.PENDING_SUBMISSION) + .submission( + CardPushTransfer.Submission.builder() + .retrievalReferenceNumber("retrieval_reference_number") + .senderReference("sender_reference") + .submittedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceNumber("trace_number") + .build() + ) + .type(CardPushTransfer.Type.CARD_PUSH_TRANSFER) + .build() + ) + .nextCursor("v57w5d") + .build() + + assertThat(cardPushTransferListPageResponse.data()) + .containsExactly( + CardPushTransfer.builder() + .id("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .acceptance( + CardPushTransfer.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .authorizationIdentificationResponse( + "authorization_identification_response" + ) + .cardVerificationValue2Result( + CardPushTransfer.Acceptance.CardVerificationValue2Result.MATCH + ) + .networkTransactionIdentifier("network_transaction_identifier") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .amount(100L) + .approval( + CardPushTransfer.Approval.builder() + .approvedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .approvedBy("approved_by") + .build() + ) + .businessApplicationIdentifier( + CardPushTransfer.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cancellation( + CardPushTransfer.Cancellation.builder() + .canceledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .canceledBy("canceled_by") + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardPushTransfer.CreatedBy.builder() + .apiKey( + CardPushTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardPushTransfer.CreatedBy.Category.USER) + .oauthApplication( + CardPushTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardPushTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .currency(CardPushTransfer.Currency.USD) + .decline( + CardPushTransfer.Decline.builder() + .declinedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkTransactionIdentifier("network_transaction_identifier") + .reason(CardPushTransfer.Decline.Reason.DO_NOT_HONOR) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(CardPushTransfer.Status.PENDING_SUBMISSION) + .submission( + CardPushTransfer.Submission.builder() + .retrievalReferenceNumber("retrieval_reference_number") + .senderReference("sender_reference") + .submittedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceNumber("trace_number") + .build() + ) + .type(CardPushTransfer.Type.CARD_PUSH_TRANSFER) + .build() + ) + assertThat(cardPushTransferListPageResponse.nextCursor()).contains("v57w5d") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardPushTransferListPageResponse = + CardPushTransferListPageResponse.builder() + .addData( + CardPushTransfer.builder() + .id("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .acceptance( + CardPushTransfer.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .authorizationIdentificationResponse( + "authorization_identification_response" + ) + .cardVerificationValue2Result( + CardPushTransfer.Acceptance.CardVerificationValue2Result.MATCH + ) + .networkTransactionIdentifier("network_transaction_identifier") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .amount(100L) + .approval( + CardPushTransfer.Approval.builder() + .approvedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .approvedBy("approved_by") + .build() + ) + .businessApplicationIdentifier( + CardPushTransfer.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cancellation( + CardPushTransfer.Cancellation.builder() + .canceledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .canceledBy("canceled_by") + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardPushTransfer.CreatedBy.builder() + .apiKey( + CardPushTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardPushTransfer.CreatedBy.Category.USER) + .oauthApplication( + CardPushTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardPushTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .currency(CardPushTransfer.Currency.USD) + .decline( + CardPushTransfer.Decline.builder() + .declinedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkTransactionIdentifier("network_transaction_identifier") + .reason(CardPushTransfer.Decline.Reason.DO_NOT_HONOR) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(CardPushTransfer.Status.PENDING_SUBMISSION) + .submission( + CardPushTransfer.Submission.builder() + .retrievalReferenceNumber("retrieval_reference_number") + .senderReference("sender_reference") + .submittedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceNumber("trace_number") + .build() + ) + .type(CardPushTransfer.Type.CARD_PUSH_TRANSFER) + .build() + ) + .nextCursor("v57w5d") + .build() + + val roundtrippedCardPushTransferListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardPushTransferListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardPushTransferListPageResponse) + .isEqualTo(cardPushTransferListPageResponse) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListParamsTest.kt new file mode 100644 index 000000000..af7fe0b23 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferListParamsTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.increase.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferListParamsTest { + + @Test + fun create() { + CardPushTransferListParams.builder() + .accountId("account_id") + .createdAt( + CardPushTransferListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .status( + CardPushTransferListParams.Status.builder() + .addIn(CardPushTransferListParams.Status.In.PENDING_APPROVAL) + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + CardPushTransferListParams.builder() + .accountId("account_id") + .createdAt( + CardPushTransferListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .status( + CardPushTransferListParams.Status.builder() + .addIn(CardPushTransferListParams.Status.In.PENDING_APPROVAL) + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("account_id", "account_id") + .put("created_at.after", "2019-12-27T18:11:19.117Z") + .put("created_at.before", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_before", "2019-12-27T18:11:19.117Z") + .put("cursor", "cursor") + .put("idempotency_key", "x") + .put("limit", "1") + .put("status.in", listOf("pending_approval").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CardPushTransferListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferRetrieveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferRetrieveParamsTest.kt new file mode 100644 index 000000000..cab63d74c --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferRetrieveParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferRetrieveParamsTest { + + @Test + fun create() { + CardPushTransferRetrieveParams.builder() + .cardPushTransferId("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .build() + } + + @Test + fun pathParams() { + val params = + CardPushTransferRetrieveParams.builder() + .cardPushTransferId("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .build() + + assertThat(params._pathParam(0)) + .isEqualTo("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferTest.kt new file mode 100644 index 000000000..37e7292a8 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpushtransfers/CardPushTransferTest.kt @@ -0,0 +1,287 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardpushtransfers + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardPushTransferTest { + + @Test + fun create() { + val cardPushTransfer = + CardPushTransfer.builder() + .id("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .acceptance( + CardPushTransfer.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .authorizationIdentificationResponse( + "authorization_identification_response" + ) + .cardVerificationValue2Result( + CardPushTransfer.Acceptance.CardVerificationValue2Result.MATCH + ) + .networkTransactionIdentifier("network_transaction_identifier") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .amount(100L) + .approval( + CardPushTransfer.Approval.builder() + .approvedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .approvedBy("approved_by") + .build() + ) + .businessApplicationIdentifier( + CardPushTransfer.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cancellation( + CardPushTransfer.Cancellation.builder() + .canceledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .canceledBy("canceled_by") + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardPushTransfer.CreatedBy.builder() + .apiKey( + CardPushTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardPushTransfer.CreatedBy.Category.USER) + .oauthApplication( + CardPushTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardPushTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .currency(CardPushTransfer.Currency.USD) + .decline( + CardPushTransfer.Decline.builder() + .declinedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkTransactionIdentifier("network_transaction_identifier") + .reason(CardPushTransfer.Decline.Reason.DO_NOT_HONOR) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(CardPushTransfer.Status.PENDING_SUBMISSION) + .submission( + CardPushTransfer.Submission.builder() + .retrievalReferenceNumber("retrieval_reference_number") + .senderReference("sender_reference") + .submittedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceNumber("trace_number") + .build() + ) + .type(CardPushTransfer.Type.CARD_PUSH_TRANSFER) + .build() + + assertThat(cardPushTransfer.id()) + .isEqualTo("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + assertThat(cardPushTransfer.acceptance()) + .contains( + CardPushTransfer.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .authorizationIdentificationResponse("authorization_identification_response") + .cardVerificationValue2Result( + CardPushTransfer.Acceptance.CardVerificationValue2Result.MATCH + ) + .networkTransactionIdentifier("network_transaction_identifier") + .build() + ) + assertThat(cardPushTransfer.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(cardPushTransfer.amount()).isEqualTo(100L) + assertThat(cardPushTransfer.approval()) + .contains( + CardPushTransfer.Approval.builder() + .approvedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .approvedBy("approved_by") + .build() + ) + assertThat(cardPushTransfer.businessApplicationIdentifier()) + .isEqualTo(CardPushTransfer.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT) + assertThat(cardPushTransfer.cancellation()) + .contains( + CardPushTransfer.Cancellation.builder() + .canceledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .canceledBy("canceled_by") + .build() + ) + assertThat(cardPushTransfer.createdAt()) + .isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + assertThat(cardPushTransfer.createdBy()) + .contains( + CardPushTransfer.CreatedBy.builder() + .apiKey( + CardPushTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardPushTransfer.CreatedBy.Category.USER) + .oauthApplication( + CardPushTransfer.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user( + CardPushTransfer.CreatedBy.User.builder().email("user@example.com").build() + ) + .build() + ) + assertThat(cardPushTransfer.currency()).isEqualTo(CardPushTransfer.Currency.USD) + assertThat(cardPushTransfer.decline()) + .contains( + CardPushTransfer.Decline.builder() + .declinedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkTransactionIdentifier("network_transaction_identifier") + .reason(CardPushTransfer.Decline.Reason.DO_NOT_HONOR) + .build() + ) + assertThat(cardPushTransfer.idempotencyKey()).isEmpty + assertThat(cardPushTransfer.merchantCategoryCode()).isEqualTo("1234") + assertThat(cardPushTransfer.merchantCityName()).isEqualTo("New York") + assertThat(cardPushTransfer.merchantName()).isEqualTo("Acme Corp") + assertThat(cardPushTransfer.merchantNamePrefix()).isEqualTo("Acme") + assertThat(cardPushTransfer.merchantPostalCode()).isEqualTo("10045") + assertThat(cardPushTransfer.merchantState()).isEqualTo("NY") + assertThat(cardPushTransfer.recipientName()).isEqualTo("Ian Crease") + assertThat(cardPushTransfer.senderAddressCity()).isEqualTo("New York") + assertThat(cardPushTransfer.senderAddressLine1()).isEqualTo("33 Liberty Street") + assertThat(cardPushTransfer.senderAddressPostalCode()).isEqualTo("10045") + assertThat(cardPushTransfer.senderAddressState()).isEqualTo("NY") + assertThat(cardPushTransfer.senderName()).isEqualTo("Ian Crease") + assertThat(cardPushTransfer.sourceAccountNumberId()) + .isEqualTo("account_number_v18nkfqm6afpsrvy82b2") + assertThat(cardPushTransfer.status()).isEqualTo(CardPushTransfer.Status.PENDING_SUBMISSION) + assertThat(cardPushTransfer.submission()) + .contains( + CardPushTransfer.Submission.builder() + .retrievalReferenceNumber("retrieval_reference_number") + .senderReference("sender_reference") + .submittedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceNumber("trace_number") + .build() + ) + assertThat(cardPushTransfer.type()).isEqualTo(CardPushTransfer.Type.CARD_PUSH_TRANSFER) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardPushTransfer = + CardPushTransfer.builder() + .id("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + .acceptance( + CardPushTransfer.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .authorizationIdentificationResponse( + "authorization_identification_response" + ) + .cardVerificationValue2Result( + CardPushTransfer.Acceptance.CardVerificationValue2Result.MATCH + ) + .networkTransactionIdentifier("network_transaction_identifier") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .amount(100L) + .approval( + CardPushTransfer.Approval.builder() + .approvedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .approvedBy("approved_by") + .build() + ) + .businessApplicationIdentifier( + CardPushTransfer.BusinessApplicationIdentifier.FUNDS_DISBURSEMENT + ) + .cancellation( + CardPushTransfer.Cancellation.builder() + .canceledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .canceledBy("canceled_by") + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardPushTransfer.CreatedBy.builder() + .apiKey( + CardPushTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardPushTransfer.CreatedBy.Category.USER) + .oauthApplication( + CardPushTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardPushTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .currency(CardPushTransfer.Currency.USD) + .decline( + CardPushTransfer.Decline.builder() + .declinedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkTransactionIdentifier("network_transaction_identifier") + .reason(CardPushTransfer.Decline.Reason.DO_NOT_HONOR) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(CardPushTransfer.Status.PENDING_SUBMISSION) + .submission( + CardPushTransfer.Submission.builder() + .retrievalReferenceNumber("retrieval_reference_number") + .senderReference("sender_reference") + .submittedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .traceNumber("trace_number") + .build() + ) + .type(CardPushTransfer.Type.CARD_PUSH_TRANSFER) + .build() + + val roundtrippedCardPushTransfer = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardPushTransfer), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardPushTransfer).isEqualTo(cardPushTransfer) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesParamsTest.kt new file mode 100644 index 000000000..b657e57fc --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenCapabilitiesParamsTest { + + @Test + fun create() { + CardTokenCapabilitiesParams.builder() + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .build() + } + + @Test + fun pathParams() { + val params = + CardTokenCapabilitiesParams.builder() + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .build() + + assertThat(params._pathParam(0)).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesTest.kt new file mode 100644 index 000000000..e6a20a84e --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenCapabilitiesTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenCapabilitiesTest { + + @Test + fun create() { + val cardTokenCapabilities = + CardTokenCapabilities.builder() + .addRoute( + CardTokenCapabilities.Route.builder() + .crossBorderPushTransfers( + CardTokenCapabilities.Route.CrossBorderPushTransfers.NOT_SUPPORTED + ) + .domesticPushTransfers( + CardTokenCapabilities.Route.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCapabilities.Route.InnerRoute.VISA) + .build() + ) + .type(CardTokenCapabilities.Type.CARD_TOKEN_CAPABILITIES) + .build() + + assertThat(cardTokenCapabilities.routes()) + .containsExactly( + CardTokenCapabilities.Route.builder() + .crossBorderPushTransfers( + CardTokenCapabilities.Route.CrossBorderPushTransfers.NOT_SUPPORTED + ) + .domesticPushTransfers( + CardTokenCapabilities.Route.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCapabilities.Route.InnerRoute.VISA) + .build() + ) + assertThat(cardTokenCapabilities.type()) + .isEqualTo(CardTokenCapabilities.Type.CARD_TOKEN_CAPABILITIES) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardTokenCapabilities = + CardTokenCapabilities.builder() + .addRoute( + CardTokenCapabilities.Route.builder() + .crossBorderPushTransfers( + CardTokenCapabilities.Route.CrossBorderPushTransfers.NOT_SUPPORTED + ) + .domesticPushTransfers( + CardTokenCapabilities.Route.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCapabilities.Route.InnerRoute.VISA) + .build() + ) + .type(CardTokenCapabilities.Type.CARD_TOKEN_CAPABILITIES) + .build() + + val roundtrippedCardTokenCapabilities = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardTokenCapabilities), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardTokenCapabilities).isEqualTo(cardTokenCapabilities) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenListPageResponseTest.kt new file mode 100644 index 000000000..c1bfd4133 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenListPageResponseTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenListPageResponseTest { + + @Test + fun create() { + val cardTokenListPageResponse = + CardTokenListPageResponse.builder() + .addData( + CardToken.builder() + .id("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .expirationDate(LocalDate.parse("2020-01-31")) + .last4("1234") + .length(16L) + .prefix("46637100") + .type(CardToken.Type.CARD_TOKEN) + .build() + ) + .nextCursor("v57w5d") + .build() + + assertThat(cardTokenListPageResponse.data()) + .containsExactly( + CardToken.builder() + .id("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .expirationDate(LocalDate.parse("2020-01-31")) + .last4("1234") + .length(16L) + .prefix("46637100") + .type(CardToken.Type.CARD_TOKEN) + .build() + ) + assertThat(cardTokenListPageResponse.nextCursor()).contains("v57w5d") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardTokenListPageResponse = + CardTokenListPageResponse.builder() + .addData( + CardToken.builder() + .id("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .expirationDate(LocalDate.parse("2020-01-31")) + .last4("1234") + .length(16L) + .prefix("46637100") + .type(CardToken.Type.CARD_TOKEN) + .build() + ) + .nextCursor("v57w5d") + .build() + + val roundtrippedCardTokenListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardTokenListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardTokenListPageResponse).isEqualTo(cardTokenListPageResponse) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenListParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenListParamsTest.kt new file mode 100644 index 000000000..f2c595a97 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenListParamsTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.increase.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenListParamsTest { + + @Test + fun create() { + CardTokenListParams.builder() + .createdAt( + CardTokenListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .limit(1L) + .build() + } + + @Test + fun queryParams() { + val params = + CardTokenListParams.builder() + .createdAt( + CardTokenListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .limit(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("created_at.after", "2019-12-27T18:11:19.117Z") + .put("created_at.before", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_before", "2019-12-27T18:11:19.117Z") + .put("cursor", "cursor") + .put("limit", "1") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CardTokenListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenRetrieveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenRetrieveParamsTest.kt new file mode 100644 index 000000000..ff536b043 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenRetrieveParamsTest { + + @Test + fun create() { + CardTokenRetrieveParams.builder() + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .build() + } + + @Test + fun pathParams() { + val params = + CardTokenRetrieveParams.builder() + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .build() + + assertThat(params._pathParam(0)).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenTest.kt new file mode 100644 index 000000000..03a54e9fa --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardtokens/CardTokenTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardtokens + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenTest { + + @Test + fun create() { + val cardToken = + CardToken.builder() + .id("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .expirationDate(LocalDate.parse("2020-01-31")) + .last4("1234") + .length(16L) + .prefix("46637100") + .type(CardToken.Type.CARD_TOKEN) + .build() + + assertThat(cardToken.id()).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + assertThat(cardToken.createdAt()).isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + assertThat(cardToken.expirationDate()).isEqualTo(LocalDate.parse("2020-01-31")) + assertThat(cardToken.last4()).isEqualTo("1234") + assertThat(cardToken.length()).isEqualTo(16L) + assertThat(cardToken.prefix()).isEqualTo("46637100") + assertThat(cardToken.type()).isEqualTo(CardToken.Type.CARD_TOKEN) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardToken = + CardToken.builder() + .id("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .expirationDate(LocalDate.parse("2020-01-31")) + .last4("1234") + .length(16L) + .prefix("46637100") + .type(CardToken.Type.CARD_TOKEN) + .build() + + val roundtrippedCardToken = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardToken), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardToken).isEqualTo(cardToken) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationCreateParamsTest.kt new file mode 100644 index 000000000..4165624b6 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationCreateParamsTest.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardValidationCreateParamsTest { + + @Test + fun create() { + CardValidationCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .build() + } + + @Test + fun body() { + val params = + CardValidationCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .build() + + val body = params._body() + + assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(body.cardTokenId()).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + assertThat(body.merchantCategoryCode()).isEqualTo("1234") + assertThat(body.merchantCityName()).isEqualTo("New York") + assertThat(body.merchantName()).isEqualTo("Acme Corp") + assertThat(body.merchantPostalCode()).isEqualTo("10045") + assertThat(body.merchantState()).isEqualTo("NY") + assertThat(body.cardholderFirstName()).contains("Dee") + assertThat(body.cardholderLastName()).contains("Hock") + assertThat(body.cardholderMiddleName()).contains("Ward") + assertThat(body.cardholderPostalCode()).contains("10045") + assertThat(body.cardholderStreetAddress()).contains("33 Liberty Street") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CardValidationCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .build() + + val body = params._body() + + assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(body.cardTokenId()).isEqualTo("outbound_card_token_zlt0ml6youq3q7vcdlg0") + assertThat(body.merchantCategoryCode()).isEqualTo("1234") + assertThat(body.merchantCityName()).isEqualTo("New York") + assertThat(body.merchantName()).isEqualTo("Acme Corp") + assertThat(body.merchantPostalCode()).isEqualTo("10045") + assertThat(body.merchantState()).isEqualTo("NY") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageResponseTest.kt new file mode 100644 index 000000000..ffe7cb111 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationListPageResponseTest.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardValidationListPageResponseTest { + + @Test + fun create() { + val cardValidationListPageResponse = + CardValidationListPageResponse.builder() + .addData( + CardValidation.builder() + .id("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .acceptance( + CardValidation.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .authorizationIdentificationResponse("ABCDEF") + .cardVerificationValue2Result(null) + .cardholderFirstNameResult(null) + .cardholderFullNameResult(null) + .cardholderLastNameResult(null) + .cardholderMiddleNameResult(null) + .cardholderPostalCodeResult(null) + .cardholderStreetAddressResult(null) + .networkTransactionIdentifier("841488484271872") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardValidation.CreatedBy.builder() + .apiKey( + CardValidation.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardValidation.CreatedBy.Category.USER) + .oauthApplication( + CardValidation.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardValidation.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .decline( + CardValidation.Decline.builder() + .declinedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .networkTransactionIdentifier("841488484271872") + .reason( + CardValidation.Decline.Reason + .TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + ) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .status(CardValidation.Status.PENDING_SUBMISSION) + .submission( + CardValidation.Submission.builder() + .retrievalReferenceNumber("123456789012") + .submittedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .traceNumber("123456") + .build() + ) + .type(CardValidation.Type.CARD_VALIDATION) + .build() + ) + .nextCursor("v57w5d") + .build() + + assertThat(cardValidationListPageResponse.data()) + .containsExactly( + CardValidation.builder() + .id("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .acceptance( + CardValidation.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .authorizationIdentificationResponse("ABCDEF") + .cardVerificationValue2Result(null) + .cardholderFirstNameResult(null) + .cardholderFullNameResult(null) + .cardholderLastNameResult(null) + .cardholderMiddleNameResult(null) + .cardholderPostalCodeResult(null) + .cardholderStreetAddressResult(null) + .networkTransactionIdentifier("841488484271872") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardValidation.CreatedBy.builder() + .apiKey( + CardValidation.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardValidation.CreatedBy.Category.USER) + .oauthApplication( + CardValidation.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardValidation.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .decline( + CardValidation.Decline.builder() + .declinedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .networkTransactionIdentifier("841488484271872") + .reason( + CardValidation.Decline.Reason + .TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + ) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .status(CardValidation.Status.PENDING_SUBMISSION) + .submission( + CardValidation.Submission.builder() + .retrievalReferenceNumber("123456789012") + .submittedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .traceNumber("123456") + .build() + ) + .type(CardValidation.Type.CARD_VALIDATION) + .build() + ) + assertThat(cardValidationListPageResponse.nextCursor()).contains("v57w5d") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardValidationListPageResponse = + CardValidationListPageResponse.builder() + .addData( + CardValidation.builder() + .id("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .acceptance( + CardValidation.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .authorizationIdentificationResponse("ABCDEF") + .cardVerificationValue2Result(null) + .cardholderFirstNameResult(null) + .cardholderFullNameResult(null) + .cardholderLastNameResult(null) + .cardholderMiddleNameResult(null) + .cardholderPostalCodeResult(null) + .cardholderStreetAddressResult(null) + .networkTransactionIdentifier("841488484271872") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardValidation.CreatedBy.builder() + .apiKey( + CardValidation.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardValidation.CreatedBy.Category.USER) + .oauthApplication( + CardValidation.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + CardValidation.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .decline( + CardValidation.Decline.builder() + .declinedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .networkTransactionIdentifier("841488484271872") + .reason( + CardValidation.Decline.Reason + .TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + ) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .status(CardValidation.Status.PENDING_SUBMISSION) + .submission( + CardValidation.Submission.builder() + .retrievalReferenceNumber("123456789012") + .submittedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .traceNumber("123456") + .build() + ) + .type(CardValidation.Type.CARD_VALIDATION) + .build() + ) + .nextCursor("v57w5d") + .build() + + val roundtrippedCardValidationListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardValidationListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardValidationListPageResponse) + .isEqualTo(cardValidationListPageResponse) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationListParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationListParamsTest.kt new file mode 100644 index 000000000..b4a40d115 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationListParamsTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.increase.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardValidationListParamsTest { + + @Test + fun create() { + CardValidationListParams.builder() + .accountId("account_id") + .createdAt( + CardValidationListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .status( + CardValidationListParams.Status.builder() + .addIn(CardValidationListParams.Status.In.REQUIRES_ATTENTION) + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + CardValidationListParams.builder() + .accountId("account_id") + .createdAt( + CardValidationListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .status( + CardValidationListParams.Status.builder() + .addIn(CardValidationListParams.Status.In.REQUIRES_ATTENTION) + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("account_id", "account_id") + .put("created_at.after", "2019-12-27T18:11:19.117Z") + .put("created_at.before", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_before", "2019-12-27T18:11:19.117Z") + .put("cursor", "cursor") + .put("idempotency_key", "x") + .put("limit", "1") + .put("status.in", listOf("requires_attention").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CardValidationListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationRetrieveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationRetrieveParamsTest.kt new file mode 100644 index 000000000..9706cffe4 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardValidationRetrieveParamsTest { + + @Test + fun create() { + CardValidationRetrieveParams.builder() + .cardValidationId("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .build() + } + + @Test + fun pathParams() { + val params = + CardValidationRetrieveParams.builder() + .cardValidationId("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .build() + + assertThat(params._pathParam(0)).isEqualTo("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationTest.kt new file mode 100644 index 000000000..2b9ac7ab2 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardvalidations/CardValidationTest.kt @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.cardvalidations + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardValidationTest { + + @Test + fun create() { + val cardValidation = + CardValidation.builder() + .id("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .acceptance( + CardValidation.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .authorizationIdentificationResponse("ABCDEF") + .cardVerificationValue2Result(null) + .cardholderFirstNameResult(null) + .cardholderFullNameResult(null) + .cardholderLastNameResult(null) + .cardholderMiddleNameResult(null) + .cardholderPostalCodeResult(null) + .cardholderStreetAddressResult(null) + .networkTransactionIdentifier("841488484271872") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardValidation.CreatedBy.builder() + .apiKey( + CardValidation.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardValidation.CreatedBy.Category.USER) + .oauthApplication( + CardValidation.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user( + CardValidation.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .decline( + CardValidation.Decline.builder() + .declinedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .networkTransactionIdentifier("841488484271872") + .reason( + CardValidation.Decline.Reason.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + ) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .status(CardValidation.Status.PENDING_SUBMISSION) + .submission( + CardValidation.Submission.builder() + .retrievalReferenceNumber("123456789012") + .submittedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .traceNumber("123456") + .build() + ) + .type(CardValidation.Type.CARD_VALIDATION) + .build() + + assertThat(cardValidation.id()).isEqualTo("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + assertThat(cardValidation.acceptance()) + .contains( + CardValidation.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .authorizationIdentificationResponse("ABCDEF") + .cardVerificationValue2Result(null) + .cardholderFirstNameResult(null) + .cardholderFullNameResult(null) + .cardholderLastNameResult(null) + .cardholderMiddleNameResult(null) + .cardholderPostalCodeResult(null) + .cardholderStreetAddressResult(null) + .networkTransactionIdentifier("841488484271872") + .build() + ) + assertThat(cardValidation.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(cardValidation.cardholderFirstName()).contains("Dee") + assertThat(cardValidation.cardholderLastName()).contains("Hock") + assertThat(cardValidation.cardholderMiddleName()).contains("Ward") + assertThat(cardValidation.cardholderPostalCode()).contains("10045") + assertThat(cardValidation.cardholderStreetAddress()).contains("33 Liberty Street") + assertThat(cardValidation.createdAt()) + .isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + assertThat(cardValidation.createdBy()) + .contains( + CardValidation.CreatedBy.builder() + .apiKey( + CardValidation.CreatedBy.ApiKey.builder().description("description").build() + ) + .category(CardValidation.CreatedBy.Category.USER) + .oauthApplication( + CardValidation.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user(CardValidation.CreatedBy.User.builder().email("user@example.com").build()) + .build() + ) + assertThat(cardValidation.decline()) + .contains( + CardValidation.Decline.builder() + .declinedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .networkTransactionIdentifier("841488484271872") + .reason(CardValidation.Decline.Reason.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER) + .build() + ) + assertThat(cardValidation.idempotencyKey()).isEmpty + assertThat(cardValidation.merchantCategoryCode()).isEqualTo("1234") + assertThat(cardValidation.merchantCityName()).isEqualTo("New York") + assertThat(cardValidation.merchantName()).isEqualTo("Acme Corp") + assertThat(cardValidation.merchantPostalCode()).isEqualTo("10045") + assertThat(cardValidation.merchantState()).isEqualTo("NY") + assertThat(cardValidation.status()).isEqualTo(CardValidation.Status.PENDING_SUBMISSION) + assertThat(cardValidation.submission()) + .contains( + CardValidation.Submission.builder() + .retrievalReferenceNumber("123456789012") + .submittedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .traceNumber("123456") + .build() + ) + assertThat(cardValidation.type()).isEqualTo(CardValidation.Type.CARD_VALIDATION) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardValidation = + CardValidation.builder() + .id("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + .acceptance( + CardValidation.Acceptance.builder() + .acceptedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .authorizationIdentificationResponse("ABCDEF") + .cardVerificationValue2Result(null) + .cardholderFirstNameResult(null) + .cardholderFullNameResult(null) + .cardholderLastNameResult(null) + .cardholderMiddleNameResult(null) + .cardholderPostalCodeResult(null) + .cardholderStreetAddressResult(null) + .networkTransactionIdentifier("841488484271872") + .build() + ) + .accountId("account_in71c4amph0vgo2qllky") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + CardValidation.CreatedBy.builder() + .apiKey( + CardValidation.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(CardValidation.CreatedBy.Category.USER) + .oauthApplication( + CardValidation.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user( + CardValidation.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .decline( + CardValidation.Decline.builder() + .declinedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .networkTransactionIdentifier("841488484271872") + .reason( + CardValidation.Decline.Reason.TRANSACTION_NOT_PERMITTED_TO_CARDHOLDER + ) + .build() + ) + .idempotencyKey(null) + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .status(CardValidation.Status.PENDING_SUBMISSION) + .submission( + CardValidation.Submission.builder() + .retrievalReferenceNumber("123456789012") + .submittedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .traceNumber("123456") + .build() + ) + .type(CardValidation.Type.CARD_VALIDATION) + .build() + + val roundtrippedCardValidation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardValidation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardValidation).isEqualTo(cardValidation) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardtokens/CardTokenCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardtokens/CardTokenCreateParamsTest.kt new file mode 100644 index 000000000..e737f6eca --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardtokens/CardTokenCreateParamsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardtokens + +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTokenCreateParamsTest { + + @Test + fun create() { + CardTokenCreateParams.builder() + .addCapability( + CardTokenCreateParams.Capability.builder() + .crossBorderPushTransfers( + CardTokenCreateParams.Capability.CrossBorderPushTransfers.SUPPORTED + ) + .domesticPushTransfers( + CardTokenCreateParams.Capability.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCreateParams.Capability.Route.VISA) + .build() + ) + .expiration(LocalDate.parse("2019-12-27")) + .last4("1234") + .prefix("41234567") + .primaryAccountNumberLength(16L) + .build() + } + + @Test + fun body() { + val params = + CardTokenCreateParams.builder() + .addCapability( + CardTokenCreateParams.Capability.builder() + .crossBorderPushTransfers( + CardTokenCreateParams.Capability.CrossBorderPushTransfers.SUPPORTED + ) + .domesticPushTransfers( + CardTokenCreateParams.Capability.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCreateParams.Capability.Route.VISA) + .build() + ) + .expiration(LocalDate.parse("2019-12-27")) + .last4("1234") + .prefix("41234567") + .primaryAccountNumberLength(16L) + .build() + + val body = params._body() + + assertThat(body.capabilities().getOrNull()) + .containsExactly( + CardTokenCreateParams.Capability.builder() + .crossBorderPushTransfers( + CardTokenCreateParams.Capability.CrossBorderPushTransfers.SUPPORTED + ) + .domesticPushTransfers( + CardTokenCreateParams.Capability.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCreateParams.Capability.Route.VISA) + .build() + ) + assertThat(body.expiration()).contains(LocalDate.parse("2019-12-27")) + assertThat(body.last4()).contains("1234") + assertThat(body.prefix()).contains("41234567") + assertThat(body.primaryAccountNumberLength()).contains(16L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = CardTokenCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardPushTransferServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardPushTransferServiceAsyncTest.kt new file mode 100644 index 000000000..72f4833c7 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardPushTransferServiceAsyncTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardPushTransferServiceAsyncTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferServiceAsync = client.cardPushTransfers() + + val cardPushTransferFuture = + cardPushTransferServiceAsync.create( + CardPushTransferCreateParams.builder() + .amount(100L) + .businessApplicationIdentifier( + CardPushTransferCreateParams.BusinessApplicationIdentifier + .FUNDS_DISBURSEMENT + ) + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .requireApproval(true) + .build() + ) + + val cardPushTransfer = cardPushTransferFuture.get() + cardPushTransfer.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferServiceAsync = client.cardPushTransfers() + + val cardPushTransferFuture = + cardPushTransferServiceAsync.retrieve( + "outbound_card_push_transfer_e0z9rdpamraczh4tvwye" + ) + + val cardPushTransfer = cardPushTransferFuture.get() + cardPushTransfer.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferServiceAsync = client.cardPushTransfers() + + val pageFuture = cardPushTransferServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun approve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferServiceAsync = client.cardPushTransfers() + + val cardPushTransferFuture = + cardPushTransferServiceAsync.approve("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + + val cardPushTransfer = cardPushTransferFuture.get() + cardPushTransfer.validate() + } + + @Test + fun cancel() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferServiceAsync = client.cardPushTransfers() + + val cardPushTransferFuture = + cardPushTransferServiceAsync.cancel("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + + val cardPushTransfer = cardPushTransferFuture.get() + cardPushTransfer.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardTokenServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardTokenServiceAsyncTest.kt new file mode 100644 index 000000000..63f41f4f6 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardTokenServiceAsyncTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardTokenServiceAsyncTest { + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenServiceAsync = client.cardTokens() + + val cardTokenFuture = + cardTokenServiceAsync.retrieve("outbound_card_token_zlt0ml6youq3q7vcdlg0") + + val cardToken = cardTokenFuture.get() + cardToken.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenServiceAsync = client.cardTokens() + + val pageFuture = cardTokenServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun capabilities() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenServiceAsync = client.cardTokens() + + val cardTokenCapabilitiesFuture = + cardTokenServiceAsync.capabilities("outbound_card_token_zlt0ml6youq3q7vcdlg0") + + val cardTokenCapabilities = cardTokenCapabilitiesFuture.get() + cardTokenCapabilities.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardValidationServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardValidationServiceAsyncTest.kt new file mode 100644 index 000000000..0d70a2259 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardValidationServiceAsyncTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.models.cardvalidations.CardValidationCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardValidationServiceAsyncTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardValidationServiceAsync = client.cardValidations() + + val cardValidationFuture = + cardValidationServiceAsync.create( + CardValidationCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .build() + ) + + val cardValidation = cardValidationFuture.get() + cardValidation.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardValidationServiceAsync = client.cardValidations() + + val cardValidationFuture = + cardValidationServiceAsync.retrieve("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + + val cardValidation = cardValidationFuture.get() + cardValidation.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardValidationServiceAsync = client.cardValidations() + + val pageFuture = cardValidationServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsyncTest.kt new file mode 100644 index 000000000..25424a30d --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardTokenServiceAsyncTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.models.simulations.cardtokens.CardTokenCreateParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardTokenServiceAsyncTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenServiceAsync = client.simulations().cardTokens() + + val cardTokenFuture = + cardTokenServiceAsync.create( + CardTokenCreateParams.builder() + .addCapability( + CardTokenCreateParams.Capability.builder() + .crossBorderPushTransfers( + CardTokenCreateParams.Capability.CrossBorderPushTransfers.SUPPORTED + ) + .domesticPushTransfers( + CardTokenCreateParams.Capability.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCreateParams.Capability.Route.VISA) + .build() + ) + .expiration(LocalDate.parse("2019-12-27")) + .last4("1234") + .prefix("41234567") + .primaryAccountNumberLength(16L) + .build() + ) + + val cardToken = cardTokenFuture.get() + cardToken.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardPushTransferServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardPushTransferServiceTest.kt new file mode 100644 index 000000000..eda8e3105 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardPushTransferServiceTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardPushTransferServiceTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferService = client.cardPushTransfers() + + val cardPushTransfer = + cardPushTransferService.create( + CardPushTransferCreateParams.builder() + .amount(100L) + .businessApplicationIdentifier( + CardPushTransferCreateParams.BusinessApplicationIdentifier + .FUNDS_DISBURSEMENT + ) + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantNamePrefix("Acme") + .merchantPostalCode("10045") + .merchantState("NY") + .recipientName("Ian Crease") + .senderAddressCity("New York") + .senderAddressLine1("33 Liberty Street") + .senderAddressPostalCode("10045") + .senderAddressState("NY") + .senderName("Ian Crease") + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .requireApproval(true) + .build() + ) + + cardPushTransfer.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferService = client.cardPushTransfers() + + val cardPushTransfer = + cardPushTransferService.retrieve("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + + cardPushTransfer.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferService = client.cardPushTransfers() + + val page = cardPushTransferService.list() + + page.response().validate() + } + + @Test + fun approve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferService = client.cardPushTransfers() + + val cardPushTransfer = + cardPushTransferService.approve("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + + cardPushTransfer.validate() + } + + @Test + fun cancel() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardPushTransferService = client.cardPushTransfers() + + val cardPushTransfer = + cardPushTransferService.cancel("outbound_card_push_transfer_e0z9rdpamraczh4tvwye") + + cardPushTransfer.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardTokenServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardTokenServiceTest.kt new file mode 100644 index 000000000..636c60786 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardTokenServiceTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardTokenServiceTest { + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenService = client.cardTokens() + + val cardToken = cardTokenService.retrieve("outbound_card_token_zlt0ml6youq3q7vcdlg0") + + cardToken.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenService = client.cardTokens() + + val page = cardTokenService.list() + + page.response().validate() + } + + @Test + fun capabilities() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenService = client.cardTokens() + + val cardTokenCapabilities = + cardTokenService.capabilities("outbound_card_token_zlt0ml6youq3q7vcdlg0") + + cardTokenCapabilities.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardValidationServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardValidationServiceTest.kt new file mode 100644 index 000000000..c17f21ca5 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardValidationServiceTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.models.cardvalidations.CardValidationCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardValidationServiceTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardValidationService = client.cardValidations() + + val cardValidation = + cardValidationService.create( + CardValidationCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0") + .merchantCategoryCode("1234") + .merchantCityName("New York") + .merchantName("Acme Corp") + .merchantPostalCode("10045") + .merchantState("NY") + .cardholderFirstName("Dee") + .cardholderLastName("Hock") + .cardholderMiddleName("Ward") + .cardholderPostalCode("10045") + .cardholderStreetAddress("33 Liberty Street") + .build() + ) + + cardValidation.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardValidationService = client.cardValidations() + + val cardValidation = + cardValidationService.retrieve("outbound_card_validation_qqlzagpc6v1x2gcdhe24") + + cardValidation.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardValidationService = client.cardValidations() + + val page = cardValidationService.list() + + page.response().validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardTokenServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardTokenServiceTest.kt new file mode 100644 index 000000000..0a3ccc5f6 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardTokenServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.models.simulations.cardtokens.CardTokenCreateParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardTokenServiceTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardTokenService = client.simulations().cardTokens() + + val cardToken = + cardTokenService.create( + CardTokenCreateParams.builder() + .addCapability( + CardTokenCreateParams.Capability.builder() + .crossBorderPushTransfers( + CardTokenCreateParams.Capability.CrossBorderPushTransfers.SUPPORTED + ) + .domesticPushTransfers( + CardTokenCreateParams.Capability.DomesticPushTransfers.SUPPORTED + ) + .route(CardTokenCreateParams.Capability.Route.VISA) + .build() + ) + .expiration(LocalDate.parse("2019-12-27")) + .last4("1234") + .prefix("41234567") + .primaryAccountNumberLength(16L) + .build() + ) + + cardToken.validate() + } +} diff --git a/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt b/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt index 0d0eb29c2..6de79bce7 100644 --- a/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt +++ b/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt @@ -100,6 +100,9 @@ internal class ProGuardCompatibilityTest { assertThat(client.intrafiAccountEnrollments()).isNotNull() assertThat(client.intrafiBalances()).isNotNull() assertThat(client.intrafiExclusions()).isNotNull() + assertThat(client.cardTokens()).isNotNull() + assertThat(client.cardPushTransfers()).isNotNull() + assertThat(client.cardValidations()).isNotNull() assertThat(client.simulations()).isNotNull() }