From ec6669584ccc894314cf256a01e1ae78652c8aa6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:26:46 +0000 Subject: [PATCH 1/2] feat(api): api update --- .stats.yml | 8 +- .../com/increase/api/client/IncreaseClient.kt | 5 + .../api/client/IncreaseClientAsync.kt | 5 + .../api/client/IncreaseClientAsyncImpl.kt | 14 + .../increase/api/client/IncreaseClientImpl.kt | 14 + .../models/swifttransfers/SwiftTransfer.kt | 3315 +++++++++++++++++ .../SwiftTransferApproveParams.kt | 242 ++ .../SwiftTransferCancelParams.kt | 242 ++ .../SwiftTransferCreateParams.kt | 2245 +++++++++++ .../swifttransfers/SwiftTransferListPage.kt | 133 + .../SwiftTransferListPageAsync.kt | 148 + .../SwiftTransferListPageResponse.kt | 240 ++ .../swifttransfers/SwiftTransferListParams.kt | 822 ++++ .../SwiftTransferRetrieveParams.kt | 201 + .../async/SwiftTransferServiceAsync.kt | 341 ++ .../async/SwiftTransferServiceAsyncImpl.kt | 261 ++ .../services/blocking/SwiftTransferService.kt | 342 ++ .../blocking/SwiftTransferServiceImpl.kt | 244 ++ .../SwiftTransferApproveParamsTest.kt | 28 + .../SwiftTransferCancelParamsTest.kt | 28 + .../SwiftTransferCreateParamsTest.kt | 180 + .../SwiftTransferListPageResponseTest.kt | 230 ++ .../SwiftTransferListParamsTest.kt | 84 + .../SwiftTransferRetrieveParamsTest.kt | 28 + .../swifttransfers/SwiftTransferTest.kt | 206 + .../async/SwiftTransferServiceAsyncTest.kt | 126 + .../blocking/SwiftTransferServiceTest.kt | 118 + .../api/proguard/ProGuardCompatibilityTest.kt | 1 + 28 files changed, 9847 insertions(+), 4 deletions(-) create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransfer.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPage.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageAsync.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponse.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferRetrieveParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsync.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncImpl.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferService.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferServiceImpl.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponseTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferRetrieveParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/blocking/SwiftTransferServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 6f42a9fee..af0e17b5e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 227 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-0281c1d774b1853b7b09bbce88b8d6e0301179b68d53627c5940edd7d2f8b180.yml -openapi_spec_hash: e22a9d6a4f0f32976d0ac9dd7e6d7dd0 -config_hash: ca52ca9a2968f330339fd50c1a386e05 +configured_endpoints: 232 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-7a47821c7d33caac95ba05890682dde6da257dbe86033e4f119aa626c11ae387.yml +openapi_spec_hash: 0ccabc90834936bc2fcdeeee01e77a64 +config_hash: 8a9bb9e2d5dd0ccc3e78ad59f924fd3c 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 e3f11a5cb..45a95b6a6 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 @@ -56,6 +56,7 @@ import com.increase.api.services.blocking.RealTimePaymentsTransferService import com.increase.api.services.blocking.RoutingNumberService import com.increase.api.services.blocking.SimulationService import com.increase.api.services.blocking.SupplementalDocumentService +import com.increase.api.services.blocking.SwiftTransferService import com.increase.api.services.blocking.TransactionService import com.increase.api.services.blocking.WebhookService import com.increase.api.services.blocking.WireDrawdownRequestService @@ -152,6 +153,8 @@ interface IncreaseClient { fun inboundFednowTransfers(): InboundFednowTransferService + fun swiftTransfers(): SwiftTransferService + fun checkDeposits(): CheckDepositService fun lockboxes(): LockboxService @@ -290,6 +293,8 @@ interface IncreaseClient { fun inboundFednowTransfers(): InboundFednowTransferService.WithRawResponse + fun swiftTransfers(): SwiftTransferService.WithRawResponse + fun checkDeposits(): CheckDepositService.WithRawResponse fun lockboxes(): LockboxService.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 5f2257a8f..869f37b2a 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 @@ -56,6 +56,7 @@ import com.increase.api.services.async.RealTimePaymentsTransferServiceAsync import com.increase.api.services.async.RoutingNumberServiceAsync import com.increase.api.services.async.SimulationServiceAsync import com.increase.api.services.async.SupplementalDocumentServiceAsync +import com.increase.api.services.async.SwiftTransferServiceAsync import com.increase.api.services.async.TransactionServiceAsync import com.increase.api.services.async.WebhookServiceAsync import com.increase.api.services.async.WireDrawdownRequestServiceAsync @@ -152,6 +153,8 @@ interface IncreaseClientAsync { fun inboundFednowTransfers(): InboundFednowTransferServiceAsync + fun swiftTransfers(): SwiftTransferServiceAsync + fun checkDeposits(): CheckDepositServiceAsync fun lockboxes(): LockboxServiceAsync @@ -294,6 +297,8 @@ interface IncreaseClientAsync { fun inboundFednowTransfers(): InboundFednowTransferServiceAsync.WithRawResponse + fun swiftTransfers(): SwiftTransferServiceAsync.WithRawResponse + fun checkDeposits(): CheckDepositServiceAsync.WithRawResponse fun lockboxes(): LockboxServiceAsync.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 ffd99e1dd..6691e016c 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 @@ -110,6 +110,8 @@ import com.increase.api.services.async.SimulationServiceAsync import com.increase.api.services.async.SimulationServiceAsyncImpl import com.increase.api.services.async.SupplementalDocumentServiceAsync import com.increase.api.services.async.SupplementalDocumentServiceAsyncImpl +import com.increase.api.services.async.SwiftTransferServiceAsync +import com.increase.api.services.async.SwiftTransferServiceAsyncImpl import com.increase.api.services.async.TransactionServiceAsync import com.increase.api.services.async.TransactionServiceAsyncImpl import com.increase.api.services.async.WebhookServiceAsync @@ -244,6 +246,10 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa InboundFednowTransferServiceAsyncImpl(clientOptionsWithUserAgent) } + private val swiftTransfers: SwiftTransferServiceAsync by lazy { + SwiftTransferServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val checkDeposits: CheckDepositServiceAsync by lazy { CheckDepositServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -426,6 +432,8 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun inboundFednowTransfers(): InboundFednowTransferServiceAsync = inboundFednowTransfers + override fun swiftTransfers(): SwiftTransferServiceAsync = swiftTransfers + override fun checkDeposits(): CheckDepositServiceAsync = checkDeposits override fun lockboxes(): LockboxServiceAsync = lockboxes @@ -605,6 +613,10 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa InboundFednowTransferServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val swiftTransfers: SwiftTransferServiceAsync.WithRawResponse by lazy { + SwiftTransferServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val checkDeposits: CheckDepositServiceAsync.WithRawResponse by lazy { CheckDepositServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -801,6 +813,8 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun inboundFednowTransfers(): InboundFednowTransferServiceAsync.WithRawResponse = inboundFednowTransfers + override fun swiftTransfers(): SwiftTransferServiceAsync.WithRawResponse = swiftTransfers + override fun checkDeposits(): CheckDepositServiceAsync.WithRawResponse = checkDeposits override fun lockboxes(): LockboxServiceAsync.WithRawResponse = lockboxes 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 411587c38..9d3e2f55f 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 @@ -110,6 +110,8 @@ import com.increase.api.services.blocking.SimulationService import com.increase.api.services.blocking.SimulationServiceImpl import com.increase.api.services.blocking.SupplementalDocumentService import com.increase.api.services.blocking.SupplementalDocumentServiceImpl +import com.increase.api.services.blocking.SwiftTransferService +import com.increase.api.services.blocking.SwiftTransferServiceImpl import com.increase.api.services.blocking.TransactionService import com.increase.api.services.blocking.TransactionServiceImpl import com.increase.api.services.blocking.WebhookService @@ -241,6 +243,10 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli InboundFednowTransferServiceImpl(clientOptionsWithUserAgent) } + private val swiftTransfers: SwiftTransferService by lazy { + SwiftTransferServiceImpl(clientOptionsWithUserAgent) + } + private val checkDeposits: CheckDepositService by lazy { CheckDepositServiceImpl(clientOptionsWithUserAgent) } @@ -409,6 +415,8 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun inboundFednowTransfers(): InboundFednowTransferService = inboundFednowTransfers + override fun swiftTransfers(): SwiftTransferService = swiftTransfers + override fun checkDeposits(): CheckDepositService = checkDeposits override fun lockboxes(): LockboxService = lockboxes @@ -586,6 +594,10 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli InboundFednowTransferServiceImpl.WithRawResponseImpl(clientOptions) } + private val swiftTransfers: SwiftTransferService.WithRawResponse by lazy { + SwiftTransferServiceImpl.WithRawResponseImpl(clientOptions) + } + private val checkDeposits: CheckDepositService.WithRawResponse by lazy { CheckDepositServiceImpl.WithRawResponseImpl(clientOptions) } @@ -780,6 +792,8 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun inboundFednowTransfers(): InboundFednowTransferService.WithRawResponse = inboundFednowTransfers + override fun swiftTransfers(): SwiftTransferService.WithRawResponse = swiftTransfers + override fun checkDeposits(): CheckDepositService.WithRawResponse = checkDeposits override fun lockboxes(): LockboxService.WithRawResponse = lockboxes diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransfer.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransfer.kt new file mode 100644 index 000000000..2029132e6 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransfer.kt @@ -0,0 +1,3315 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 + +/** Swift Transfers send funds internationally. */ +class SwiftTransfer +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val accountId: JsonField, + private val accountNumber: JsonField, + private val amount: JsonField, + private val bankIdentificationCode: JsonField, + private val createdAt: JsonField, + private val createdBy: JsonField, + private val creditorAddress: JsonField, + private val creditorName: JsonField, + private val debtorAddress: JsonField, + private val debtorName: JsonField, + private val idempotencyKey: JsonField, + private val instructedAmount: JsonField, + private val instructedCurrency: JsonField, + private val pendingTransactionId: JsonField, + private val routingNumber: JsonField, + private val sourceAccountNumberId: JsonField, + private val status: JsonField, + private val transactionId: JsonField, + private val type: JsonField, + private val uniqueEndToEndTransactionReference: JsonField, + private val unstructuredRemittanceInformation: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("account_number") + @ExcludeMissing + accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("bank_identification_code") + @ExcludeMissing + bankIdentificationCode: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("created_by") + @ExcludeMissing + createdBy: JsonField = JsonMissing.of(), + @JsonProperty("creditor_address") + @ExcludeMissing + creditorAddress: JsonField = JsonMissing.of(), + @JsonProperty("creditor_name") + @ExcludeMissing + creditorName: JsonField = JsonMissing.of(), + @JsonProperty("debtor_address") + @ExcludeMissing + debtorAddress: JsonField = JsonMissing.of(), + @JsonProperty("debtor_name") + @ExcludeMissing + debtorName: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_key") + @ExcludeMissing + idempotencyKey: JsonField = JsonMissing.of(), + @JsonProperty("instructed_amount") + @ExcludeMissing + instructedAmount: JsonField = JsonMissing.of(), + @JsonProperty("instructed_currency") + @ExcludeMissing + instructedCurrency: JsonField = JsonMissing.of(), + @JsonProperty("pending_transaction_id") + @ExcludeMissing + pendingTransactionId: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("source_account_number_id") + @ExcludeMissing + sourceAccountNumberId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("unique_end_to_end_transaction_reference") + @ExcludeMissing + uniqueEndToEndTransactionReference: JsonField = JsonMissing.of(), + @JsonProperty("unstructured_remittance_information") + @ExcludeMissing + unstructuredRemittanceInformation: JsonField = JsonMissing.of(), + ) : this( + id, + accountId, + accountNumber, + amount, + bankIdentificationCode, + createdAt, + createdBy, + creditorAddress, + creditorName, + debtorAddress, + debtorName, + idempotencyKey, + instructedAmount, + instructedCurrency, + pendingTransactionId, + routingNumber, + sourceAccountNumberId, + status, + transactionId, + type, + uniqueEndToEndTransactionReference, + unstructuredRemittanceInformation, + mutableMapOf(), + ) + + /** + * The Swift 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") + + /** + * The Account to which the transfer belongs. + * + * @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 creditor's account 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 accountNumber(): String = accountNumber.getRequired("account_number") + + /** + * 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") + + /** + * The bank identification code (BIC) of the creditor. + * + * @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 bankIdentificationCode(): String = + bankIdentificationCode.getRequired("bank_identification_code") + + /** + * 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 or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdBy(): CreatedBy = createdBy.getRequired("created_by") + + /** + * The creditor's address. + * + * @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 creditorAddress(): CreditorAddress = creditorAddress.getRequired("creditor_address") + + /** + * The creditor's 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 creditorName(): String = creditorName.getRequired("creditor_name") + + /** + * The debtor's address. + * + * @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 debtorAddress(): DebtorAddress = debtorAddress.getRequired("debtor_address") + + /** + * The debtor's 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 debtorName(): String = debtorName.getRequired("debtor_name") + + /** + * 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 amount that was instructed to be transferred in minor units of the `instructed_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 instructedAmount(): Long = instructedAmount.getRequired("instructed_amount") + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + * + * @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 instructedCurrency(): InstructedCurrency = + instructedCurrency.getRequired("instructed_currency") + + /** + * The ID for the pending transaction representing the transfer. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingTransactionId(): Optional = + pendingTransactionId.getOptional("pending_transaction_id") + + /** + * The creditor's bank account routing or transit number. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingNumber(): Optional = routingNumber.getOptional("routing_number") + + /** + * The Account Number included in the transfer as the debtor's account 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 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") + + /** + * The ID for the transaction funding the transfer. This will be populated after the transfer is + * initiated. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * A constant representing the object's type. For this resource it will always be + * `swift_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") + + /** + * The Unique End-to-end Transaction Reference + * ([UETR](https://www.swift.com/payments/what-unique-end-end-transaction-reference-uetr)) 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 uniqueEndToEndTransactionReference(): String = + uniqueEndToEndTransactionReference.getRequired("unique_end_to_end_transaction_reference") + + /** + * The unstructured remittance information that was included with 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 unstructuredRemittanceInformation(): String = + unstructuredRemittanceInformation.getRequired("unstructured_remittance_information") + + /** + * 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 [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 [accountNumber]. + * + * Unlike [accountNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber + + /** + * 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 [bankIdentificationCode]. + * + * Unlike [bankIdentificationCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bank_identification_code") + @ExcludeMissing + fun _bankIdentificationCode(): JsonField = bankIdentificationCode + + /** + * 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 [creditorAddress]. + * + * Unlike [creditorAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creditor_address") + @ExcludeMissing + fun _creditorAddress(): JsonField = creditorAddress + + /** + * Returns the raw JSON value of [creditorName]. + * + * Unlike [creditorName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creditor_name") + @ExcludeMissing + fun _creditorName(): JsonField = creditorName + + /** + * Returns the raw JSON value of [debtorAddress]. + * + * Unlike [debtorAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("debtor_address") + @ExcludeMissing + fun _debtorAddress(): JsonField = debtorAddress + + /** + * Returns the raw JSON value of [debtorName]. + * + * Unlike [debtorName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("debtor_name") @ExcludeMissing fun _debtorName(): JsonField = debtorName + + /** + * 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 [instructedAmount]. + * + * Unlike [instructedAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("instructed_amount") + @ExcludeMissing + fun _instructedAmount(): JsonField = instructedAmount + + /** + * Returns the raw JSON value of [instructedCurrency]. + * + * Unlike [instructedCurrency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("instructed_currency") + @ExcludeMissing + fun _instructedCurrency(): JsonField = instructedCurrency + + /** + * Returns the raw JSON value of [pendingTransactionId]. + * + * Unlike [pendingTransactionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_transaction_id") + @ExcludeMissing + fun _pendingTransactionId(): JsonField = pendingTransactionId + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** + * 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 [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [uniqueEndToEndTransactionReference]. + * + * Unlike [uniqueEndToEndTransactionReference], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unique_end_to_end_transaction_reference") + @ExcludeMissing + fun _uniqueEndToEndTransactionReference(): JsonField = + uniqueEndToEndTransactionReference + + /** + * Returns the raw JSON value of [unstructuredRemittanceInformation]. + * + * Unlike [unstructuredRemittanceInformation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unstructured_remittance_information") + @ExcludeMissing + fun _unstructuredRemittanceInformation(): JsonField = unstructuredRemittanceInformation + + @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 [SwiftTransfer]. + * + * The following fields are required: + * ```java + * .id() + * .accountId() + * .accountNumber() + * .amount() + * .bankIdentificationCode() + * .createdAt() + * .createdBy() + * .creditorAddress() + * .creditorName() + * .debtorAddress() + * .debtorName() + * .idempotencyKey() + * .instructedAmount() + * .instructedCurrency() + * .pendingTransactionId() + * .routingNumber() + * .sourceAccountNumberId() + * .status() + * .transactionId() + * .type() + * .uniqueEndToEndTransactionReference() + * .unstructuredRemittanceInformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransfer]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var accountId: JsonField? = null + private var accountNumber: JsonField? = null + private var amount: JsonField? = null + private var bankIdentificationCode: JsonField? = null + private var createdAt: JsonField? = null + private var createdBy: JsonField? = null + private var creditorAddress: JsonField? = null + private var creditorName: JsonField? = null + private var debtorAddress: JsonField? = null + private var debtorName: JsonField? = null + private var idempotencyKey: JsonField? = null + private var instructedAmount: JsonField? = null + private var instructedCurrency: JsonField? = null + private var pendingTransactionId: JsonField? = null + private var routingNumber: JsonField? = null + private var sourceAccountNumberId: JsonField? = null + private var status: JsonField? = null + private var transactionId: JsonField? = null + private var type: JsonField? = null + private var uniqueEndToEndTransactionReference: JsonField? = null + private var unstructuredRemittanceInformation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(swiftTransfer: SwiftTransfer) = apply { + id = swiftTransfer.id + accountId = swiftTransfer.accountId + accountNumber = swiftTransfer.accountNumber + amount = swiftTransfer.amount + bankIdentificationCode = swiftTransfer.bankIdentificationCode + createdAt = swiftTransfer.createdAt + createdBy = swiftTransfer.createdBy + creditorAddress = swiftTransfer.creditorAddress + creditorName = swiftTransfer.creditorName + debtorAddress = swiftTransfer.debtorAddress + debtorName = swiftTransfer.debtorName + idempotencyKey = swiftTransfer.idempotencyKey + instructedAmount = swiftTransfer.instructedAmount + instructedCurrency = swiftTransfer.instructedCurrency + pendingTransactionId = swiftTransfer.pendingTransactionId + routingNumber = swiftTransfer.routingNumber + sourceAccountNumberId = swiftTransfer.sourceAccountNumberId + status = swiftTransfer.status + transactionId = swiftTransfer.transactionId + type = swiftTransfer.type + uniqueEndToEndTransactionReference = swiftTransfer.uniqueEndToEndTransactionReference + unstructuredRemittanceInformation = swiftTransfer.unstructuredRemittanceInformation + additionalProperties = swiftTransfer.additionalProperties.toMutableMap() + } + + /** The Swift 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 } + + /** The Account to which the transfer belongs. */ + 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 creditor's account number. */ + fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + + /** + * Sets [Builder.accountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.accountNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + + /** 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 } + + /** The bank identification code (BIC) of the creditor. */ + fun bankIdentificationCode(bankIdentificationCode: String) = + bankIdentificationCode(JsonField.of(bankIdentificationCode)) + + /** + * Sets [Builder.bankIdentificationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.bankIdentificationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bankIdentificationCode(bankIdentificationCode: JsonField) = apply { + this.bankIdentificationCode = bankIdentificationCode + } + + /** + * 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.of(createdBy)) + + /** + * 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 creditor's address. */ + fun creditorAddress(creditorAddress: CreditorAddress) = + creditorAddress(JsonField.of(creditorAddress)) + + /** + * Sets [Builder.creditorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.creditorAddress] with a well-typed [CreditorAddress] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditorAddress(creditorAddress: JsonField) = apply { + this.creditorAddress = creditorAddress + } + + /** The creditor's name. */ + fun creditorName(creditorName: String) = creditorName(JsonField.of(creditorName)) + + /** + * Sets [Builder.creditorName] to an arbitrary JSON value. + * + * You should usually call [Builder.creditorName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditorName(creditorName: JsonField) = apply { + this.creditorName = creditorName + } + + /** The debtor's address. */ + fun debtorAddress(debtorAddress: DebtorAddress) = debtorAddress(JsonField.of(debtorAddress)) + + /** + * Sets [Builder.debtorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.debtorAddress] with a well-typed [DebtorAddress] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun debtorAddress(debtorAddress: JsonField) = apply { + this.debtorAddress = debtorAddress + } + + /** The debtor's name. */ + fun debtorName(debtorName: String) = debtorName(JsonField.of(debtorName)) + + /** + * Sets [Builder.debtorName] to an arbitrary JSON value. + * + * You should usually call [Builder.debtorName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun debtorName(debtorName: JsonField) = apply { this.debtorName = debtorName } + + /** + * 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 amount that was instructed to be transferred in minor units of the + * `instructed_currency`. + */ + fun instructedAmount(instructedAmount: Long) = + instructedAmount(JsonField.of(instructedAmount)) + + /** + * Sets [Builder.instructedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.instructedAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instructedAmount(instructedAmount: JsonField) = apply { + this.instructedAmount = instructedAmount + } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + */ + fun instructedCurrency(instructedCurrency: InstructedCurrency) = + instructedCurrency(JsonField.of(instructedCurrency)) + + /** + * Sets [Builder.instructedCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.instructedCurrency] with a well-typed + * [InstructedCurrency] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instructedCurrency(instructedCurrency: JsonField) = apply { + this.instructedCurrency = instructedCurrency + } + + /** The ID for the pending transaction representing the transfer. */ + fun pendingTransactionId(pendingTransactionId: String?) = + pendingTransactionId(JsonField.ofNullable(pendingTransactionId)) + + /** + * Alias for calling [Builder.pendingTransactionId] with + * `pendingTransactionId.orElse(null)`. + */ + fun pendingTransactionId(pendingTransactionId: Optional) = + pendingTransactionId(pendingTransactionId.getOrNull()) + + /** + * Sets [Builder.pendingTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingTransactionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingTransactionId(pendingTransactionId: JsonField) = apply { + this.pendingTransactionId = pendingTransactionId + } + + /** The creditor's bank account routing or transit number. Required in certain countries. */ + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) + + /** Alias for calling [Builder.routingNumber] with `routingNumber.orElse(null)`. */ + fun routingNumber(routingNumber: Optional) = + routingNumber(routingNumber.getOrNull()) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + /** The Account Number included in the transfer as the debtor's account number. */ + 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 } + + /** + * The ID for the transaction funding the transfer. This will be populated after the + * transfer is initiated. + */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** + * A constant representing the object's type. For this resource it will always be + * `swift_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 } + + /** + * The Unique End-to-end Transaction Reference + * ([UETR](https://www.swift.com/payments/what-unique-end-end-transaction-reference-uetr)) + * for the transfer. + */ + fun uniqueEndToEndTransactionReference(uniqueEndToEndTransactionReference: String) = + uniqueEndToEndTransactionReference(JsonField.of(uniqueEndToEndTransactionReference)) + + /** + * Sets [Builder.uniqueEndToEndTransactionReference] to an arbitrary JSON value. + * + * You should usually call [Builder.uniqueEndToEndTransactionReference] with a well-typed + * [String] value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun uniqueEndToEndTransactionReference( + uniqueEndToEndTransactionReference: JsonField + ) = apply { this.uniqueEndToEndTransactionReference = uniqueEndToEndTransactionReference } + + /** The unstructured remittance information that was included with the transfer. */ + fun unstructuredRemittanceInformation(unstructuredRemittanceInformation: String) = + unstructuredRemittanceInformation(JsonField.of(unstructuredRemittanceInformation)) + + /** + * Sets [Builder.unstructuredRemittanceInformation] to an arbitrary JSON value. + * + * You should usually call [Builder.unstructuredRemittanceInformation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun unstructuredRemittanceInformation( + unstructuredRemittanceInformation: JsonField + ) = apply { this.unstructuredRemittanceInformation = unstructuredRemittanceInformation } + + 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 [SwiftTransfer]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accountId() + * .accountNumber() + * .amount() + * .bankIdentificationCode() + * .createdAt() + * .createdBy() + * .creditorAddress() + * .creditorName() + * .debtorAddress() + * .debtorName() + * .idempotencyKey() + * .instructedAmount() + * .instructedCurrency() + * .pendingTransactionId() + * .routingNumber() + * .sourceAccountNumberId() + * .status() + * .transactionId() + * .type() + * .uniqueEndToEndTransactionReference() + * .unstructuredRemittanceInformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SwiftTransfer = + SwiftTransfer( + checkRequired("id", id), + checkRequired("accountId", accountId), + checkRequired("accountNumber", accountNumber), + checkRequired("amount", amount), + checkRequired("bankIdentificationCode", bankIdentificationCode), + checkRequired("createdAt", createdAt), + checkRequired("createdBy", createdBy), + checkRequired("creditorAddress", creditorAddress), + checkRequired("creditorName", creditorName), + checkRequired("debtorAddress", debtorAddress), + checkRequired("debtorName", debtorName), + checkRequired("idempotencyKey", idempotencyKey), + checkRequired("instructedAmount", instructedAmount), + checkRequired("instructedCurrency", instructedCurrency), + checkRequired("pendingTransactionId", pendingTransactionId), + checkRequired("routingNumber", routingNumber), + checkRequired("sourceAccountNumberId", sourceAccountNumberId), + checkRequired("status", status), + checkRequired("transactionId", transactionId), + checkRequired("type", type), + checkRequired( + "uniqueEndToEndTransactionReference", + uniqueEndToEndTransactionReference, + ), + checkRequired( + "unstructuredRemittanceInformation", + unstructuredRemittanceInformation, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SwiftTransfer = apply { + if (validated) { + return@apply + } + + id() + accountId() + accountNumber() + amount() + bankIdentificationCode() + createdAt() + createdBy().validate() + creditorAddress().validate() + creditorName() + debtorAddress().validate() + debtorName() + idempotencyKey() + instructedAmount() + instructedCurrency().validate() + pendingTransactionId() + routingNumber() + sourceAccountNumberId() + status().validate() + transactionId() + type().validate() + uniqueEndToEndTransactionReference() + unstructuredRemittanceInformation() + 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 (accountId.asKnown().isPresent) 1 else 0) + + (if (accountNumber.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (bankIdentificationCode.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (createdBy.asKnown().getOrNull()?.validity() ?: 0) + + (creditorAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (creditorName.asKnown().isPresent) 1 else 0) + + (debtorAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (debtorName.asKnown().isPresent) 1 else 0) + + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + (if (instructedAmount.asKnown().isPresent) 1 else 0) + + (instructedCurrency.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingTransactionId.asKnown().isPresent) 1 else 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + (if (sourceAccountNumberId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (uniqueEndToEndTransactionReference.asKnown().isPresent) 1 else 0) + + (if (unstructuredRemittanceInformation.asKnown().isPresent) 1 else 0) + + /** What object created the transfer, either via the API or the dashboard. */ + class CreatedBy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 creditor's address. */ + class CreditorAddress + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val city: JsonField, + private val country: JsonField, + private val line1: JsonField, + private val line2: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) + + /** + * The city, district, town, or village of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun city(): Optional = city.getOptional("city") + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * The first line of the address. + * + * @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 line1(): String = line1.getRequired("line1") + + /** + * The second line of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun line2(): Optional = line2.getOptional("line2") + + /** + * The ZIP or postal code of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * The state, province, or region of the address. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [line1]. + * + * Unlike [line1], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + /** + * Returns the raw JSON value of [line2]. + * + * Unlike [line2], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @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 [CreditorAddress]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditorAddress]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditorAddress: CreditorAddress) = apply { + city = creditorAddress.city + country = creditorAddress.country + line1 = creditorAddress.line1 + line2 = creditorAddress.line2 + postalCode = creditorAddress.postalCode + state = creditorAddress.state + additionalProperties = creditorAddress.additionalProperties.toMutableMap() + } + + /** The city, district, town, or village of the address. */ + fun city(city: String?) = city(JsonField.ofNullable(city)) + + /** Alias for calling [Builder.city] with `city.orElse(null)`. */ + fun city(city: Optional) = city(city.getOrNull()) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** The first line of the address. */ + fun line1(line1: String) = line1(JsonField.of(line1)) + + /** + * Sets [Builder.line1] to an arbitrary JSON value. + * + * You should usually call [Builder.line1] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + /** The second line of the address. */ + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + /** Alias for calling [Builder.line2] with `line2.orElse(null)`. */ + fun line2(line2: Optional) = line2(line2.getOrNull()) + + /** + * Sets [Builder.line2] to an arbitrary JSON value. + * + * You should usually call [Builder.line2] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + /** The ZIP or postal code of the address. */ + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + /** Alias for calling [Builder.postalCode] with `postalCode.orElse(null)`. */ + fun postalCode(postalCode: Optional) = postalCode(postalCode.getOrNull()) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** The state, province, or region of the address. Required in certain countries. */ + fun state(state: String?) = state(JsonField.ofNullable(state)) + + /** Alias for calling [Builder.state] with `state.orElse(null)`. */ + fun state(state: Optional) = state(state.getOrNull()) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + 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 [CreditorAddress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditorAddress = + CreditorAddress( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + checkRequired("line2", line2), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditorAddress = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + postalCode() + state() + 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 (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditorAddress && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + postalCode == other.postalCode && + state == other.state && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditorAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + } + + /** The debtor's address. */ + class DebtorAddress + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val city: JsonField, + private val country: JsonField, + private val line1: JsonField, + private val line2: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) + + /** + * The city, district, town, or village of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun city(): Optional = city.getOptional("city") + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * The first line of the address. + * + * @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 line1(): String = line1.getRequired("line1") + + /** + * The second line of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun line2(): Optional = line2.getOptional("line2") + + /** + * The ZIP or postal code of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * The state, province, or region of the address. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [line1]. + * + * Unlike [line1], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + /** + * Returns the raw JSON value of [line2]. + * + * Unlike [line2], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @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 [DebtorAddress]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DebtorAddress]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(debtorAddress: DebtorAddress) = apply { + city = debtorAddress.city + country = debtorAddress.country + line1 = debtorAddress.line1 + line2 = debtorAddress.line2 + postalCode = debtorAddress.postalCode + state = debtorAddress.state + additionalProperties = debtorAddress.additionalProperties.toMutableMap() + } + + /** The city, district, town, or village of the address. */ + fun city(city: String?) = city(JsonField.ofNullable(city)) + + /** Alias for calling [Builder.city] with `city.orElse(null)`. */ + fun city(city: Optional) = city(city.getOrNull()) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** The first line of the address. */ + fun line1(line1: String) = line1(JsonField.of(line1)) + + /** + * Sets [Builder.line1] to an arbitrary JSON value. + * + * You should usually call [Builder.line1] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + /** The second line of the address. */ + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + /** Alias for calling [Builder.line2] with `line2.orElse(null)`. */ + fun line2(line2: Optional) = line2(line2.getOrNull()) + + /** + * Sets [Builder.line2] to an arbitrary JSON value. + * + * You should usually call [Builder.line2] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + /** The ZIP or postal code of the address. */ + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + /** Alias for calling [Builder.postalCode] with `postalCode.orElse(null)`. */ + fun postalCode(postalCode: Optional) = postalCode(postalCode.getOrNull()) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** The state, province, or region of the address. Required in certain countries. */ + fun state(state: String?) = state(JsonField.ofNullable(state)) + + /** Alias for calling [Builder.state] with `state.orElse(null)`. */ + fun state(state: Optional) = state(state.getOrNull()) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + 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 [DebtorAddress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DebtorAddress = + DebtorAddress( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + checkRequired("line2", line2), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DebtorAddress = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + postalCode() + state() + 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 (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DebtorAddress && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + postalCode == other.postalCode && + state == other.state && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DebtorAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + */ + class InstructedCurrency + @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 { + + /** United States Dollar */ + @JvmField val USD = of("USD") + + @JvmStatic fun of(value: String) = InstructedCurrency(JsonField.of(value)) + } + + /** An enum containing [InstructedCurrency]'s known values. */ + enum class Known { + /** United States Dollar */ + USD + } + + /** + * An enum containing [InstructedCurrency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InstructedCurrency] 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 { + /** United States Dollar */ + USD, + /** + * An enum member indicating that [InstructedCurrency] 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) { + 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) { + USD -> Known.USD + else -> throw IncreaseInvalidDataException("Unknown InstructedCurrency: $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(): InstructedCurrency = 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 InstructedCurrency && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** 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 pending initiation. */ + @JvmField val PENDING_INITIATING = of("pending_initiating") + + /** The transfer has been initiated. */ + @JvmField val INITIATED = of("initiated") + + /** The transfer has been rejected by Increase. */ + @JvmField val REJECTED = of("rejected") + + /** The transfer has been returned. */ + @JvmField val RETURNED = of("returned") + + @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 pending initiation. */ + PENDING_INITIATING, + /** The transfer has been initiated. */ + INITIATED, + /** The transfer has been rejected by Increase. */ + REJECTED, + /** The transfer has been returned. */ + RETURNED, + } + + /** + * 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 pending initiation. */ + PENDING_INITIATING, + /** The transfer has been initiated. */ + INITIATED, + /** The transfer has been rejected by Increase. */ + REJECTED, + /** The transfer has been returned. */ + RETURNED, + /** 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_INITIATING -> Value.PENDING_INITIATING + INITIATED -> Value.INITIATED + REJECTED -> Value.REJECTED + RETURNED -> Value.RETURNED + 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_INITIATING -> Known.PENDING_INITIATING + INITIATED -> Known.INITIATED + REJECTED -> Known.REJECTED + RETURNED -> Known.RETURNED + 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() + } + + /** + * A constant representing the object's type. For this resource it will always be + * `swift_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 SWIFT_TRANSFER = of("swift_transfer") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SWIFT_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 { + SWIFT_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) { + SWIFT_TRANSFER -> Value.SWIFT_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) { + SWIFT_TRANSFER -> Known.SWIFT_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 SwiftTransfer && + id == other.id && + accountId == other.accountId && + accountNumber == other.accountNumber && + amount == other.amount && + bankIdentificationCode == other.bankIdentificationCode && + createdAt == other.createdAt && + createdBy == other.createdBy && + creditorAddress == other.creditorAddress && + creditorName == other.creditorName && + debtorAddress == other.debtorAddress && + debtorName == other.debtorName && + idempotencyKey == other.idempotencyKey && + instructedAmount == other.instructedAmount && + instructedCurrency == other.instructedCurrency && + pendingTransactionId == other.pendingTransactionId && + routingNumber == other.routingNumber && + sourceAccountNumberId == other.sourceAccountNumberId && + status == other.status && + transactionId == other.transactionId && + type == other.type && + uniqueEndToEndTransactionReference == other.uniqueEndToEndTransactionReference && + unstructuredRemittanceInformation == other.unstructuredRemittanceInformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accountId, + accountNumber, + amount, + bankIdentificationCode, + createdAt, + createdBy, + creditorAddress, + creditorName, + debtorAddress, + debtorName, + idempotencyKey, + instructedAmount, + instructedCurrency, + pendingTransactionId, + routingNumber, + sourceAccountNumberId, + status, + transactionId, + type, + uniqueEndToEndTransactionReference, + unstructuredRemittanceInformation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SwiftTransfer{id=$id, accountId=$accountId, accountNumber=$accountNumber, amount=$amount, bankIdentificationCode=$bankIdentificationCode, createdAt=$createdAt, createdBy=$createdBy, creditorAddress=$creditorAddress, creditorName=$creditorName, debtorAddress=$debtorAddress, debtorName=$debtorName, idempotencyKey=$idempotencyKey, instructedAmount=$instructedAmount, instructedCurrency=$instructedCurrency, pendingTransactionId=$pendingTransactionId, routingNumber=$routingNumber, sourceAccountNumberId=$sourceAccountNumberId, status=$status, transactionId=$transactionId, type=$type, uniqueEndToEndTransactionReference=$uniqueEndToEndTransactionReference, unstructuredRemittanceInformation=$unstructuredRemittanceInformation, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParams.kt new file mode 100644 index 000000000..ba9f83b6c --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParams.kt @@ -0,0 +1,242 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 + +/** Approve a Swift Transfer */ +class SwiftTransferApproveParams +private constructor( + private val swiftTransferId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** The identifier of the Swift Transfer to approve. */ + fun swiftTransferId(): Optional = Optional.ofNullable(swiftTransferId) + + /** 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(): SwiftTransferApproveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [SwiftTransferApproveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferApproveParams]. */ + class Builder internal constructor() { + + private var swiftTransferId: 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(swiftTransferApproveParams: SwiftTransferApproveParams) = apply { + swiftTransferId = swiftTransferApproveParams.swiftTransferId + additionalHeaders = swiftTransferApproveParams.additionalHeaders.toBuilder() + additionalQueryParams = swiftTransferApproveParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + swiftTransferApproveParams.additionalBodyProperties.toMutableMap() + } + + /** The identifier of the Swift Transfer to approve. */ + fun swiftTransferId(swiftTransferId: String?) = apply { + this.swiftTransferId = swiftTransferId + } + + /** Alias for calling [Builder.swiftTransferId] with `swiftTransferId.orElse(null)`. */ + fun swiftTransferId(swiftTransferId: Optional) = + swiftTransferId(swiftTransferId.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 [SwiftTransferApproveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SwiftTransferApproveParams = + SwiftTransferApproveParams( + swiftTransferId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> swiftTransferId ?: "" + 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 SwiftTransferApproveParams && + swiftTransferId == other.swiftTransferId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + swiftTransferId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "SwiftTransferApproveParams{swiftTransferId=$swiftTransferId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParams.kt new file mode 100644 index 000000000..77001d354 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParams.kt @@ -0,0 +1,242 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 + +/** Cancel a pending Swift Transfer */ +class SwiftTransferCancelParams +private constructor( + private val swiftTransferId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** The identifier of the pending Swift Transfer to cancel. */ + fun swiftTransferId(): Optional = Optional.ofNullable(swiftTransferId) + + /** 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(): SwiftTransferCancelParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [SwiftTransferCancelParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferCancelParams]. */ + class Builder internal constructor() { + + private var swiftTransferId: 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(swiftTransferCancelParams: SwiftTransferCancelParams) = apply { + swiftTransferId = swiftTransferCancelParams.swiftTransferId + additionalHeaders = swiftTransferCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = swiftTransferCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + swiftTransferCancelParams.additionalBodyProperties.toMutableMap() + } + + /** The identifier of the pending Swift Transfer to cancel. */ + fun swiftTransferId(swiftTransferId: String?) = apply { + this.swiftTransferId = swiftTransferId + } + + /** Alias for calling [Builder.swiftTransferId] with `swiftTransferId.orElse(null)`. */ + fun swiftTransferId(swiftTransferId: Optional) = + swiftTransferId(swiftTransferId.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 [SwiftTransferCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SwiftTransferCancelParams = + SwiftTransferCancelParams( + swiftTransferId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> swiftTransferId ?: "" + 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 SwiftTransferCancelParams && + swiftTransferId == other.swiftTransferId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + swiftTransferId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "SwiftTransferCancelParams{swiftTransferId=$swiftTransferId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParams.kt new file mode 100644 index 000000000..a81c7e7df --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParams.kt @@ -0,0 +1,2245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 Swift Transfer */ +class SwiftTransferCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The identifier for the account that will 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 accountId(): String = body.accountId() + + /** + * The creditor's account 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 accountNumber(): String = body.accountNumber() + + /** + * The bank identification code (BIC) of the creditor. If it ends with the three-character + * branch code, this must be 11 characters long. Otherwise this must be 8 characters and the + * branch code will be assumed to be `XXX`. + * + * @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 bankIdentificationCode(): String = body.bankIdentificationCode() + + /** + * The creditor's address. + * + * @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 creditorAddress(): CreditorAddress = body.creditorAddress() + + /** + * The creditor's 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 creditorName(): String = body.creditorName() + + /** + * The debtor's address. + * + * @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 debtorAddress(): DebtorAddress = body.debtorAddress() + + /** + * The debtor's 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 debtorName(): String = body.debtorName() + + /** + * The amount, in minor units of `instructed_currency`, to send to the creditor. + * + * @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 instructedAmount(): Long = body.instructedAmount() + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + * + * @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 instructedCurrency(): InstructedCurrency = body.instructedCurrency() + + /** + * The Account Number to include in the transfer as the debtor's account 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 sourceAccountNumberId(): String = body.sourceAccountNumberId() + + /** + * Unstructured remittance information to include in 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 unstructuredRemittanceInformation(): String = body.unstructuredRemittanceInformation() + + /** + * 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() + + /** + * The creditor's bank account routing or transit number. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingNumber(): Optional = body.routingNumber() + + /** + * 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 [accountNumber]. + * + * Unlike [accountNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _accountNumber(): JsonField = body._accountNumber() + + /** + * Returns the raw JSON value of [bankIdentificationCode]. + * + * Unlike [bankIdentificationCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _bankIdentificationCode(): JsonField = body._bankIdentificationCode() + + /** + * Returns the raw JSON value of [creditorAddress]. + * + * Unlike [creditorAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _creditorAddress(): JsonField = body._creditorAddress() + + /** + * Returns the raw JSON value of [creditorName]. + * + * Unlike [creditorName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _creditorName(): JsonField = body._creditorName() + + /** + * Returns the raw JSON value of [debtorAddress]. + * + * Unlike [debtorAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _debtorAddress(): JsonField = body._debtorAddress() + + /** + * Returns the raw JSON value of [debtorName]. + * + * Unlike [debtorName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _debtorName(): JsonField = body._debtorName() + + /** + * Returns the raw JSON value of [instructedAmount]. + * + * Unlike [instructedAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _instructedAmount(): JsonField = body._instructedAmount() + + /** + * Returns the raw JSON value of [instructedCurrency]. + * + * Unlike [instructedCurrency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _instructedCurrency(): JsonField = body._instructedCurrency() + + /** + * 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 [unstructuredRemittanceInformation]. + * + * Unlike [unstructuredRemittanceInformation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + fun _unstructuredRemittanceInformation(): JsonField = + body._unstructuredRemittanceInformation() + + /** + * 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() + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _routingNumber(): JsonField = body._routingNumber() + + 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 [SwiftTransferCreateParams]. + * + * The following fields are required: + * ```java + * .accountId() + * .accountNumber() + * .bankIdentificationCode() + * .creditorAddress() + * .creditorName() + * .debtorAddress() + * .debtorName() + * .instructedAmount() + * .instructedCurrency() + * .sourceAccountNumberId() + * .unstructuredRemittanceInformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferCreateParams]. */ + 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(swiftTransferCreateParams: SwiftTransferCreateParams) = apply { + body = swiftTransferCreateParams.body.toBuilder() + additionalHeaders = swiftTransferCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = swiftTransferCreateParams.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] + * - [accountNumber] + * - [bankIdentificationCode] + * - [creditorAddress] + * - [creditorName] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The identifier for the account that will send the transfer. */ + 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 creditor's account number. */ + fun accountNumber(accountNumber: String) = apply { body.accountNumber(accountNumber) } + + /** + * Sets [Builder.accountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.accountNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountNumber(accountNumber: JsonField) = apply { + body.accountNumber(accountNumber) + } + + /** + * The bank identification code (BIC) of the creditor. If it ends with the three-character + * branch code, this must be 11 characters long. Otherwise this must be 8 characters and the + * branch code will be assumed to be `XXX`. + */ + fun bankIdentificationCode(bankIdentificationCode: String) = apply { + body.bankIdentificationCode(bankIdentificationCode) + } + + /** + * Sets [Builder.bankIdentificationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.bankIdentificationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bankIdentificationCode(bankIdentificationCode: JsonField) = apply { + body.bankIdentificationCode(bankIdentificationCode) + } + + /** The creditor's address. */ + fun creditorAddress(creditorAddress: CreditorAddress) = apply { + body.creditorAddress(creditorAddress) + } + + /** + * Sets [Builder.creditorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.creditorAddress] with a well-typed [CreditorAddress] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creditorAddress(creditorAddress: JsonField) = apply { + body.creditorAddress(creditorAddress) + } + + /** The creditor's name. */ + fun creditorName(creditorName: String) = apply { body.creditorName(creditorName) } + + /** + * Sets [Builder.creditorName] to an arbitrary JSON value. + * + * You should usually call [Builder.creditorName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditorName(creditorName: JsonField) = apply { + body.creditorName(creditorName) + } + + /** The debtor's address. */ + fun debtorAddress(debtorAddress: DebtorAddress) = apply { + body.debtorAddress(debtorAddress) + } + + /** + * Sets [Builder.debtorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.debtorAddress] with a well-typed [DebtorAddress] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun debtorAddress(debtorAddress: JsonField) = apply { + body.debtorAddress(debtorAddress) + } + + /** The debtor's name. */ + fun debtorName(debtorName: String) = apply { body.debtorName(debtorName) } + + /** + * Sets [Builder.debtorName] to an arbitrary JSON value. + * + * You should usually call [Builder.debtorName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun debtorName(debtorName: JsonField) = apply { body.debtorName(debtorName) } + + /** The amount, in minor units of `instructed_currency`, to send to the creditor. */ + fun instructedAmount(instructedAmount: Long) = apply { + body.instructedAmount(instructedAmount) + } + + /** + * Sets [Builder.instructedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.instructedAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instructedAmount(instructedAmount: JsonField) = apply { + body.instructedAmount(instructedAmount) + } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + */ + fun instructedCurrency(instructedCurrency: InstructedCurrency) = apply { + body.instructedCurrency(instructedCurrency) + } + + /** + * Sets [Builder.instructedCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.instructedCurrency] with a well-typed + * [InstructedCurrency] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instructedCurrency(instructedCurrency: JsonField) = apply { + body.instructedCurrency(instructedCurrency) + } + + /** The Account Number to include in the transfer as the debtor's account number. */ + 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) + } + + /** Unstructured remittance information to include in the transfer. */ + fun unstructuredRemittanceInformation(unstructuredRemittanceInformation: String) = apply { + body.unstructuredRemittanceInformation(unstructuredRemittanceInformation) + } + + /** + * Sets [Builder.unstructuredRemittanceInformation] to an arbitrary JSON value. + * + * You should usually call [Builder.unstructuredRemittanceInformation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun unstructuredRemittanceInformation( + unstructuredRemittanceInformation: JsonField + ) = apply { body.unstructuredRemittanceInformation(unstructuredRemittanceInformation) } + + /** 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) + } + + /** The creditor's bank account routing or transit number. Required in certain countries. */ + fun routingNumber(routingNumber: String) = apply { body.routingNumber(routingNumber) } + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + body.routingNumber(routingNumber) + } + + 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 [SwiftTransferCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountId() + * .accountNumber() + * .bankIdentificationCode() + * .creditorAddress() + * .creditorName() + * .debtorAddress() + * .debtorName() + * .instructedAmount() + * .instructedCurrency() + * .sourceAccountNumberId() + * .unstructuredRemittanceInformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SwiftTransferCreateParams = + SwiftTransferCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountId: JsonField, + private val accountNumber: JsonField, + private val bankIdentificationCode: JsonField, + private val creditorAddress: JsonField, + private val creditorName: JsonField, + private val debtorAddress: JsonField, + private val debtorName: JsonField, + private val instructedAmount: JsonField, + private val instructedCurrency: JsonField, + private val sourceAccountNumberId: JsonField, + private val unstructuredRemittanceInformation: JsonField, + private val requireApproval: JsonField, + private val routingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_id") + @ExcludeMissing + accountId: JsonField = JsonMissing.of(), + @JsonProperty("account_number") + @ExcludeMissing + accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("bank_identification_code") + @ExcludeMissing + bankIdentificationCode: JsonField = JsonMissing.of(), + @JsonProperty("creditor_address") + @ExcludeMissing + creditorAddress: JsonField = JsonMissing.of(), + @JsonProperty("creditor_name") + @ExcludeMissing + creditorName: JsonField = JsonMissing.of(), + @JsonProperty("debtor_address") + @ExcludeMissing + debtorAddress: JsonField = JsonMissing.of(), + @JsonProperty("debtor_name") + @ExcludeMissing + debtorName: JsonField = JsonMissing.of(), + @JsonProperty("instructed_amount") + @ExcludeMissing + instructedAmount: JsonField = JsonMissing.of(), + @JsonProperty("instructed_currency") + @ExcludeMissing + instructedCurrency: JsonField = JsonMissing.of(), + @JsonProperty("source_account_number_id") + @ExcludeMissing + sourceAccountNumberId: JsonField = JsonMissing.of(), + @JsonProperty("unstructured_remittance_information") + @ExcludeMissing + unstructuredRemittanceInformation: JsonField = JsonMissing.of(), + @JsonProperty("require_approval") + @ExcludeMissing + requireApproval: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + ) : this( + accountId, + accountNumber, + bankIdentificationCode, + creditorAddress, + creditorName, + debtorAddress, + debtorName, + instructedAmount, + instructedCurrency, + sourceAccountNumberId, + unstructuredRemittanceInformation, + requireApproval, + routingNumber, + mutableMapOf(), + ) + + /** + * The identifier for the account that will 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 accountId(): String = accountId.getRequired("account_id") + + /** + * The creditor's account 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 accountNumber(): String = accountNumber.getRequired("account_number") + + /** + * The bank identification code (BIC) of the creditor. If it ends with the three-character + * branch code, this must be 11 characters long. Otherwise this must be 8 characters and the + * branch code will be assumed to be `XXX`. + * + * @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 bankIdentificationCode(): String = + bankIdentificationCode.getRequired("bank_identification_code") + + /** + * The creditor's address. + * + * @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 creditorAddress(): CreditorAddress = creditorAddress.getRequired("creditor_address") + + /** + * The creditor's 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 creditorName(): String = creditorName.getRequired("creditor_name") + + /** + * The debtor's address. + * + * @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 debtorAddress(): DebtorAddress = debtorAddress.getRequired("debtor_address") + + /** + * The debtor's 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 debtorName(): String = debtorName.getRequired("debtor_name") + + /** + * The amount, in minor units of `instructed_currency`, to send to the creditor. + * + * @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 instructedAmount(): Long = instructedAmount.getRequired("instructed_amount") + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + * + * @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 instructedCurrency(): InstructedCurrency = + instructedCurrency.getRequired("instructed_currency") + + /** + * The Account Number to include in the transfer as the debtor's account 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 sourceAccountNumberId(): String = + sourceAccountNumberId.getRequired("source_account_number_id") + + /** + * Unstructured remittance information to include in 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 unstructuredRemittanceInformation(): String = + unstructuredRemittanceInformation.getRequired("unstructured_remittance_information") + + /** + * 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") + + /** + * The creditor's bank account routing or transit number. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun routingNumber(): Optional = routingNumber.getOptional("routing_number") + + /** + * 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 [accountNumber]. + * + * Unlike [accountNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber + + /** + * Returns the raw JSON value of [bankIdentificationCode]. + * + * Unlike [bankIdentificationCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bank_identification_code") + @ExcludeMissing + fun _bankIdentificationCode(): JsonField = bankIdentificationCode + + /** + * Returns the raw JSON value of [creditorAddress]. + * + * Unlike [creditorAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("creditor_address") + @ExcludeMissing + fun _creditorAddress(): JsonField = creditorAddress + + /** + * Returns the raw JSON value of [creditorName]. + * + * Unlike [creditorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("creditor_name") + @ExcludeMissing + fun _creditorName(): JsonField = creditorName + + /** + * Returns the raw JSON value of [debtorAddress]. + * + * Unlike [debtorAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("debtor_address") + @ExcludeMissing + fun _debtorAddress(): JsonField = debtorAddress + + /** + * Returns the raw JSON value of [debtorName]. + * + * Unlike [debtorName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("debtor_name") + @ExcludeMissing + fun _debtorName(): JsonField = debtorName + + /** + * Returns the raw JSON value of [instructedAmount]. + * + * Unlike [instructedAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("instructed_amount") + @ExcludeMissing + fun _instructedAmount(): JsonField = instructedAmount + + /** + * Returns the raw JSON value of [instructedCurrency]. + * + * Unlike [instructedCurrency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instructed_currency") + @ExcludeMissing + fun _instructedCurrency(): JsonField = instructedCurrency + + /** + * 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 [unstructuredRemittanceInformation]. + * + * Unlike [unstructuredRemittanceInformation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("unstructured_remittance_information") + @ExcludeMissing + fun _unstructuredRemittanceInformation(): JsonField = + unstructuredRemittanceInformation + + /** + * 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 + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + @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() + * .accountNumber() + * .bankIdentificationCode() + * .creditorAddress() + * .creditorName() + * .debtorAddress() + * .debtorName() + * .instructedAmount() + * .instructedCurrency() + * .sourceAccountNumberId() + * .unstructuredRemittanceInformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var accountId: JsonField? = null + private var accountNumber: JsonField? = null + private var bankIdentificationCode: JsonField? = null + private var creditorAddress: JsonField? = null + private var creditorName: JsonField? = null + private var debtorAddress: JsonField? = null + private var debtorName: JsonField? = null + private var instructedAmount: JsonField? = null + private var instructedCurrency: JsonField? = null + private var sourceAccountNumberId: JsonField? = null + private var unstructuredRemittanceInformation: JsonField? = null + private var requireApproval: JsonField = JsonMissing.of() + private var routingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + accountId = body.accountId + accountNumber = body.accountNumber + bankIdentificationCode = body.bankIdentificationCode + creditorAddress = body.creditorAddress + creditorName = body.creditorName + debtorAddress = body.debtorAddress + debtorName = body.debtorName + instructedAmount = body.instructedAmount + instructedCurrency = body.instructedCurrency + sourceAccountNumberId = body.sourceAccountNumberId + unstructuredRemittanceInformation = body.unstructuredRemittanceInformation + requireApproval = body.requireApproval + routingNumber = body.routingNumber + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The identifier for the account that will send the transfer. */ + 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 creditor's account number. */ + fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + + /** + * Sets [Builder.accountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.accountNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + + /** + * The bank identification code (BIC) of the creditor. If it ends with the + * three-character branch code, this must be 11 characters long. Otherwise this must be + * 8 characters and the branch code will be assumed to be `XXX`. + */ + fun bankIdentificationCode(bankIdentificationCode: String) = + bankIdentificationCode(JsonField.of(bankIdentificationCode)) + + /** + * Sets [Builder.bankIdentificationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.bankIdentificationCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bankIdentificationCode(bankIdentificationCode: JsonField) = apply { + this.bankIdentificationCode = bankIdentificationCode + } + + /** The creditor's address. */ + fun creditorAddress(creditorAddress: CreditorAddress) = + creditorAddress(JsonField.of(creditorAddress)) + + /** + * Sets [Builder.creditorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.creditorAddress] with a well-typed [CreditorAddress] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditorAddress(creditorAddress: JsonField) = apply { + this.creditorAddress = creditorAddress + } + + /** The creditor's name. */ + fun creditorName(creditorName: String) = creditorName(JsonField.of(creditorName)) + + /** + * Sets [Builder.creditorName] to an arbitrary JSON value. + * + * You should usually call [Builder.creditorName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditorName(creditorName: JsonField) = apply { + this.creditorName = creditorName + } + + /** The debtor's address. */ + fun debtorAddress(debtorAddress: DebtorAddress) = + debtorAddress(JsonField.of(debtorAddress)) + + /** + * Sets [Builder.debtorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.debtorAddress] with a well-typed [DebtorAddress] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun debtorAddress(debtorAddress: JsonField) = apply { + this.debtorAddress = debtorAddress + } + + /** The debtor's name. */ + fun debtorName(debtorName: String) = debtorName(JsonField.of(debtorName)) + + /** + * Sets [Builder.debtorName] to an arbitrary JSON value. + * + * You should usually call [Builder.debtorName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun debtorName(debtorName: JsonField) = apply { this.debtorName = debtorName } + + /** The amount, in minor units of `instructed_currency`, to send to the creditor. */ + fun instructedAmount(instructedAmount: Long) = + instructedAmount(JsonField.of(instructedAmount)) + + /** + * Sets [Builder.instructedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.instructedAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instructedAmount(instructedAmount: JsonField) = apply { + this.instructedAmount = instructedAmount + } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the + * instructed amount. + */ + fun instructedCurrency(instructedCurrency: InstructedCurrency) = + instructedCurrency(JsonField.of(instructedCurrency)) + + /** + * Sets [Builder.instructedCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.instructedCurrency] with a well-typed + * [InstructedCurrency] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun instructedCurrency(instructedCurrency: JsonField) = apply { + this.instructedCurrency = instructedCurrency + } + + /** The Account Number to include in the transfer as the debtor's account number. */ + 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 + } + + /** Unstructured remittance information to include in the transfer. */ + fun unstructuredRemittanceInformation(unstructuredRemittanceInformation: String) = + unstructuredRemittanceInformation(JsonField.of(unstructuredRemittanceInformation)) + + /** + * Sets [Builder.unstructuredRemittanceInformation] to an arbitrary JSON value. + * + * You should usually call [Builder.unstructuredRemittanceInformation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unstructuredRemittanceInformation( + unstructuredRemittanceInformation: JsonField + ) = apply { this.unstructuredRemittanceInformation = unstructuredRemittanceInformation } + + /** 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 + } + + /** + * The creditor's bank account routing or transit number. Required in certain countries. + */ + fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + 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() + * .accountNumber() + * .bankIdentificationCode() + * .creditorAddress() + * .creditorName() + * .debtorAddress() + * .debtorName() + * .instructedAmount() + * .instructedCurrency() + * .sourceAccountNumberId() + * .unstructuredRemittanceInformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("accountId", accountId), + checkRequired("accountNumber", accountNumber), + checkRequired("bankIdentificationCode", bankIdentificationCode), + checkRequired("creditorAddress", creditorAddress), + checkRequired("creditorName", creditorName), + checkRequired("debtorAddress", debtorAddress), + checkRequired("debtorName", debtorName), + checkRequired("instructedAmount", instructedAmount), + checkRequired("instructedCurrency", instructedCurrency), + checkRequired("sourceAccountNumberId", sourceAccountNumberId), + checkRequired( + "unstructuredRemittanceInformation", + unstructuredRemittanceInformation, + ), + requireApproval, + routingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accountId() + accountNumber() + bankIdentificationCode() + creditorAddress().validate() + creditorName() + debtorAddress().validate() + debtorName() + instructedAmount() + instructedCurrency().validate() + sourceAccountNumberId() + unstructuredRemittanceInformation() + requireApproval() + routingNumber() + 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 (accountNumber.asKnown().isPresent) 1 else 0) + + (if (bankIdentificationCode.asKnown().isPresent) 1 else 0) + + (creditorAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (creditorName.asKnown().isPresent) 1 else 0) + + (debtorAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (debtorName.asKnown().isPresent) 1 else 0) + + (if (instructedAmount.asKnown().isPresent) 1 else 0) + + (instructedCurrency.asKnown().getOrNull()?.validity() ?: 0) + + (if (sourceAccountNumberId.asKnown().isPresent) 1 else 0) + + (if (unstructuredRemittanceInformation.asKnown().isPresent) 1 else 0) + + (if (requireApproval.asKnown().isPresent) 1 else 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + accountId == other.accountId && + accountNumber == other.accountNumber && + bankIdentificationCode == other.bankIdentificationCode && + creditorAddress == other.creditorAddress && + creditorName == other.creditorName && + debtorAddress == other.debtorAddress && + debtorName == other.debtorName && + instructedAmount == other.instructedAmount && + instructedCurrency == other.instructedCurrency && + sourceAccountNumberId == other.sourceAccountNumberId && + unstructuredRemittanceInformation == other.unstructuredRemittanceInformation && + requireApproval == other.requireApproval && + routingNumber == other.routingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountId, + accountNumber, + bankIdentificationCode, + creditorAddress, + creditorName, + debtorAddress, + debtorName, + instructedAmount, + instructedCurrency, + sourceAccountNumberId, + unstructuredRemittanceInformation, + requireApproval, + routingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{accountId=$accountId, accountNumber=$accountNumber, bankIdentificationCode=$bankIdentificationCode, creditorAddress=$creditorAddress, creditorName=$creditorName, debtorAddress=$debtorAddress, debtorName=$debtorName, instructedAmount=$instructedAmount, instructedCurrency=$instructedCurrency, sourceAccountNumberId=$sourceAccountNumberId, unstructuredRemittanceInformation=$unstructuredRemittanceInformation, requireApproval=$requireApproval, routingNumber=$routingNumber, additionalProperties=$additionalProperties}" + } + + /** The creditor's address. */ + class CreditorAddress + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val city: JsonField, + private val country: JsonField, + private val line1: JsonField, + private val line2: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) + + /** + * The city, district, town, or village of the address. + * + * @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 city(): String = city.getRequired("city") + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * The first line of the address. This is usually the street number and street. + * + * @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 line1(): String = line1.getRequired("line1") + + /** + * The second line of the address. This might be the floor or room number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun line2(): Optional = line2.getOptional("line2") + + /** + * The ZIP or postal code of the address. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * The state, province, or region of the address. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [line1]. + * + * Unlike [line1], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + /** + * Returns the raw JSON value of [line2]. + * + * Unlike [line2], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @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 [CreditorAddress]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditorAddress]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditorAddress: CreditorAddress) = apply { + city = creditorAddress.city + country = creditorAddress.country + line1 = creditorAddress.line1 + line2 = creditorAddress.line2 + postalCode = creditorAddress.postalCode + state = creditorAddress.state + additionalProperties = creditorAddress.additionalProperties.toMutableMap() + } + + /** The city, district, town, or village of the address. */ + fun city(city: String) = city(JsonField.of(city)) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** The first line of the address. This is usually the street number and street. */ + fun line1(line1: String) = line1(JsonField.of(line1)) + + /** + * Sets [Builder.line1] to an arbitrary JSON value. + * + * You should usually call [Builder.line1] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + /** The second line of the address. This might be the floor or room number. */ + fun line2(line2: String) = line2(JsonField.of(line2)) + + /** + * Sets [Builder.line2] to an arbitrary JSON value. + * + * You should usually call [Builder.line2] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + /** The ZIP or postal code of the address. Required in certain countries. */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** The state, province, or region of the address. Required in certain countries. */ + fun state(state: String) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + 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 [CreditorAddress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditorAddress = + CreditorAddress( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + line2, + postalCode, + state, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditorAddress = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + postalCode() + state() + 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 (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditorAddress && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + postalCode == other.postalCode && + state == other.state && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditorAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + } + + /** The debtor's address. */ + class DebtorAddress + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val city: JsonField, + private val country: JsonField, + private val line1: JsonField, + private val line2: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) + + /** + * The city, district, town, or village of the address. + * + * @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 city(): String = city.getRequired("city") + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * The first line of the address. This is usually the street number and street. + * + * @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 line1(): String = line1.getRequired("line1") + + /** + * The second line of the address. This might be the floor or room number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun line2(): Optional = line2.getOptional("line2") + + /** + * The ZIP or postal code of the address. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * The state, province, or region of the address. Required in certain countries. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [line1]. + * + * Unlike [line1], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + /** + * Returns the raw JSON value of [line2]. + * + * Unlike [line2], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @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 [DebtorAddress]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DebtorAddress]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(debtorAddress: DebtorAddress) = apply { + city = debtorAddress.city + country = debtorAddress.country + line1 = debtorAddress.line1 + line2 = debtorAddress.line2 + postalCode = debtorAddress.postalCode + state = debtorAddress.state + additionalProperties = debtorAddress.additionalProperties.toMutableMap() + } + + /** The city, district, town, or village of the address. */ + fun city(city: String) = city(JsonField.of(city)) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** + * The two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * code for the country of the address. + */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** The first line of the address. This is usually the street number and street. */ + fun line1(line1: String) = line1(JsonField.of(line1)) + + /** + * Sets [Builder.line1] to an arbitrary JSON value. + * + * You should usually call [Builder.line1] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + /** The second line of the address. This might be the floor or room number. */ + fun line2(line2: String) = line2(JsonField.of(line2)) + + /** + * Sets [Builder.line2] to an arbitrary JSON value. + * + * You should usually call [Builder.line2] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + /** The ZIP or postal code of the address. Required in certain countries. */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** The state, province, or region of the address. Required in certain countries. */ + fun state(state: String) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + 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 [DebtorAddress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DebtorAddress = + DebtorAddress( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + line2, + postalCode, + state, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DebtorAddress = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + postalCode() + state() + 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 (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DebtorAddress && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + postalCode == other.postalCode && + state == other.state && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DebtorAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code of the instructed + * amount. + */ + class InstructedCurrency + @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 { + + /** United States Dollar */ + @JvmField val USD = of("USD") + + @JvmStatic fun of(value: String) = InstructedCurrency(JsonField.of(value)) + } + + /** An enum containing [InstructedCurrency]'s known values. */ + enum class Known { + /** United States Dollar */ + USD + } + + /** + * An enum containing [InstructedCurrency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InstructedCurrency] 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 { + /** United States Dollar */ + USD, + /** + * An enum member indicating that [InstructedCurrency] 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) { + 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) { + USD -> Known.USD + else -> throw IncreaseInvalidDataException("Unknown InstructedCurrency: $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(): InstructedCurrency = 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 InstructedCurrency && 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 SwiftTransferCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SwiftTransferCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPage.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPage.kt new file mode 100644 index 000000000..2ee377e9d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +import com.increase.api.core.AutoPager +import com.increase.api.core.Page +import com.increase.api.core.checkRequired +import com.increase.api.services.blocking.SwiftTransferService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see SwiftTransferService.list */ +class SwiftTransferListPage +private constructor( + private val service: SwiftTransferService, + private val params: SwiftTransferListParams, + private val response: SwiftTransferListPageResponse, +) : Page { + + /** + * Delegates to [SwiftTransferListPageResponse], but gracefully handles missing data. + * + * @see SwiftTransferListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [SwiftTransferListPageResponse], but gracefully handles missing data. + * + * @see SwiftTransferListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): SwiftTransferListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): SwiftTransferListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): SwiftTransferListParams = params + + /** The response that this page was parsed from. */ + fun response(): SwiftTransferListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SwiftTransferListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferListPage]. */ + class Builder internal constructor() { + + private var service: SwiftTransferService? = null + private var params: SwiftTransferListParams? = null + private var response: SwiftTransferListPageResponse? = null + + @JvmSynthetic + internal fun from(swiftTransferListPage: SwiftTransferListPage) = apply { + service = swiftTransferListPage.service + params = swiftTransferListPage.params + response = swiftTransferListPage.response + } + + fun service(service: SwiftTransferService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SwiftTransferListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SwiftTransferListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [SwiftTransferListPage]. + * + * 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(): SwiftTransferListPage = + SwiftTransferListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SwiftTransferListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "SwiftTransferListPage{service=$service, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageAsync.kt new file mode 100644 index 000000000..5680d6e82 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +import com.increase.api.core.AutoPagerAsync +import com.increase.api.core.PageAsync +import com.increase.api.core.checkRequired +import com.increase.api.services.async.SwiftTransferServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see SwiftTransferServiceAsync.list */ +class SwiftTransferListPageAsync +private constructor( + private val service: SwiftTransferServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: SwiftTransferListParams, + private val response: SwiftTransferListPageResponse, +) : PageAsync { + + /** + * Delegates to [SwiftTransferListPageResponse], but gracefully handles missing data. + * + * @see SwiftTransferListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [SwiftTransferListPageResponse], but gracefully handles missing data. + * + * @see SwiftTransferListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): SwiftTransferListParams { + 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(): SwiftTransferListParams = params + + /** The response that this page was parsed from. */ + fun response(): SwiftTransferListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SwiftTransferListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferListPageAsync]. */ + class Builder internal constructor() { + + private var service: SwiftTransferServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: SwiftTransferListParams? = null + private var response: SwiftTransferListPageResponse? = null + + @JvmSynthetic + internal fun from(swiftTransferListPageAsync: SwiftTransferListPageAsync) = apply { + service = swiftTransferListPageAsync.service + streamHandlerExecutor = swiftTransferListPageAsync.streamHandlerExecutor + params = swiftTransferListPageAsync.params + response = swiftTransferListPageAsync.response + } + + fun service(service: SwiftTransferServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: SwiftTransferListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SwiftTransferListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [SwiftTransferListPageAsync]. + * + * 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(): SwiftTransferListPageAsync = + SwiftTransferListPageAsync( + 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 SwiftTransferListPageAsync && + 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() = + "SwiftTransferListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponse.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponse.kt new file mode 100644 index 000000000..79988066e --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponse.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 Swift Transfer objects. */ +class SwiftTransferListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +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 + * [SwiftTransferListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(swiftTransferListPageResponse: SwiftTransferListPageResponse) = apply { + data = swiftTransferListPageResponse.data.map { it.toMutableList() } + nextCursor = swiftTransferListPageResponse.nextCursor + additionalProperties = swiftTransferListPageResponse.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 [SwiftTransfer] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: SwiftTransfer) = 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 [SwiftTransferListPageResponse]. + * + * 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(): SwiftTransferListPageResponse = + SwiftTransferListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextCursor", nextCursor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SwiftTransferListPageResponse = 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 SwiftTransferListPageResponse && + 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() = + "SwiftTransferListPageResponse{data=$data, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParams.kt new file mode 100644 index 000000000..2c1b209fa --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParams.kt @@ -0,0 +1,822 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 Swift Transfers */ +class SwiftTransferListParams +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 Swift Transfers to those that originated from 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(): SwiftTransferListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SwiftTransferListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferListParams]. */ + 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(swiftTransferListParams: SwiftTransferListParams) = apply { + accountId = swiftTransferListParams.accountId + createdAt = swiftTransferListParams.createdAt + cursor = swiftTransferListParams.cursor + idempotencyKey = swiftTransferListParams.idempotencyKey + limit = swiftTransferListParams.limit + status = swiftTransferListParams.status + additionalHeaders = swiftTransferListParams.additionalHeaders.toBuilder() + additionalQueryParams = swiftTransferListParams.additionalQueryParams.toBuilder() + } + + /** Filter Swift Transfers to those that originated from 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 [SwiftTransferListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SwiftTransferListParams = + SwiftTransferListParams( + 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) { + + /** + * Return results whose value is in the provided list. 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() + } + + /** + * Return results whose value is in the provided list. 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 pending initiation. */ + @JvmField val PENDING_INITIATING = of("pending_initiating") + + /** The transfer has been initiated. */ + @JvmField val INITIATED = of("initiated") + + /** The transfer has been rejected by Increase. */ + @JvmField val REJECTED = of("rejected") + + /** The transfer has been returned. */ + @JvmField val RETURNED = of("returned") + + @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 pending initiation. */ + PENDING_INITIATING, + /** The transfer has been initiated. */ + INITIATED, + /** The transfer has been rejected by Increase. */ + REJECTED, + /** The transfer has been returned. */ + RETURNED, + } + + /** + * 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 pending initiation. */ + PENDING_INITIATING, + /** The transfer has been initiated. */ + INITIATED, + /** The transfer has been rejected by Increase. */ + REJECTED, + /** The transfer has been returned. */ + RETURNED, + /** 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_INITIATING -> Value.PENDING_INITIATING + INITIATED -> Value.INITIATED + REJECTED -> Value.REJECTED + RETURNED -> Value.RETURNED + 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_INITIATING -> Known.PENDING_INITIATING + INITIATED -> Known.INITIATED + REJECTED -> Known.REJECTED + RETURNED -> Known.RETURNED + 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 SwiftTransferListParams && + 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() = + "SwiftTransferListParams{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/swifttransfers/SwiftTransferRetrieveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferRetrieveParams.kt new file mode 100644 index 000000000..06f425a09 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/swifttransfers/SwiftTransferRetrieveParams.kt @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 Swift Transfer */ +class SwiftTransferRetrieveParams +private constructor( + private val swiftTransferId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Swift Transfer. */ + fun swiftTransferId(): Optional = Optional.ofNullable(swiftTransferId) + + /** 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(): SwiftTransferRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [SwiftTransferRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SwiftTransferRetrieveParams]. */ + class Builder internal constructor() { + + private var swiftTransferId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(swiftTransferRetrieveParams: SwiftTransferRetrieveParams) = apply { + swiftTransferId = swiftTransferRetrieveParams.swiftTransferId + additionalHeaders = swiftTransferRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = swiftTransferRetrieveParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Swift Transfer. */ + fun swiftTransferId(swiftTransferId: String?) = apply { + this.swiftTransferId = swiftTransferId + } + + /** Alias for calling [Builder.swiftTransferId] with `swiftTransferId.orElse(null)`. */ + fun swiftTransferId(swiftTransferId: Optional) = + swiftTransferId(swiftTransferId.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 [SwiftTransferRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SwiftTransferRetrieveParams = + SwiftTransferRetrieveParams( + swiftTransferId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> swiftTransferId ?: "" + 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 SwiftTransferRetrieveParams && + swiftTransferId == other.swiftTransferId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(swiftTransferId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SwiftTransferRetrieveParams{swiftTransferId=$swiftTransferId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsync.kt new file mode 100644 index 000000000..5da8fbecd --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsync.kt @@ -0,0 +1,341 @@ +// 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.swifttransfers.SwiftTransfer +import com.increase.api.models.swifttransfers.SwiftTransferApproveParams +import com.increase.api.models.swifttransfers.SwiftTransferCancelParams +import com.increase.api.models.swifttransfers.SwiftTransferCreateParams +import com.increase.api.models.swifttransfers.SwiftTransferListPageAsync +import com.increase.api.models.swifttransfers.SwiftTransferListParams +import com.increase.api.models.swifttransfers.SwiftTransferRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SwiftTransferServiceAsync { + + /** + * 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): SwiftTransferServiceAsync + + /** Create a Swift Transfer */ + fun create(params: SwiftTransferCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieve a Swift Transfer */ + fun retrieve(swiftTransferId: String): CompletableFuture = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + ): CompletableFuture = retrieve(swiftTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SwiftTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: SwiftTransferRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none(), requestOptions) + + /** List Swift Transfers */ + fun list(): CompletableFuture = list(SwiftTransferListParams.none()) + + /** @see list */ + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(SwiftTransferListParams.none(), requestOptions) + + /** Approve a Swift Transfer */ + fun approve(swiftTransferId: String): CompletableFuture = + approve(swiftTransferId, SwiftTransferApproveParams.none()) + + /** @see approve */ + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + approve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see approve */ + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + ): CompletableFuture = approve(swiftTransferId, params, RequestOptions.none()) + + /** @see approve */ + fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see approve */ + fun approve(params: SwiftTransferApproveParams): CompletableFuture = + approve(params, RequestOptions.none()) + + /** @see approve */ + fun approve( + swiftTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + approve(swiftTransferId, SwiftTransferApproveParams.none(), requestOptions) + + /** Cancel a pending Swift Transfer */ + fun cancel(swiftTransferId: String): CompletableFuture = + cancel(swiftTransferId, SwiftTransferCancelParams.none()) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + ): CompletableFuture = cancel(swiftTransferId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: SwiftTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: SwiftTransferCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(swiftTransferId, SwiftTransferCancelParams.none(), requestOptions) + + /** + * A view of [SwiftTransferServiceAsync] 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 + ): SwiftTransferServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /swift_transfers`, but is otherwise the same as + * [SwiftTransferServiceAsync.create]. + */ + fun create( + params: SwiftTransferCreateParams + ): CompletableFuture> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /swift_transfers/{swift_transfer_id}`, but is + * otherwise the same as [SwiftTransferServiceAsync.retrieve]. + */ + fun retrieve(swiftTransferId: String): CompletableFuture> = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + ): CompletableFuture> = + retrieve(swiftTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SwiftTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: SwiftTransferRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /swift_transfers`, but is otherwise the same as + * [SwiftTransferServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(SwiftTransferListParams.none()) + + /** @see list */ + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(SwiftTransferListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /swift_transfers/{swift_transfer_id}/approve`, but + * is otherwise the same as [SwiftTransferServiceAsync.approve]. + */ + fun approve(swiftTransferId: String): CompletableFuture> = + approve(swiftTransferId, SwiftTransferApproveParams.none()) + + /** @see approve */ + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + approve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see approve */ + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + ): CompletableFuture> = + approve(swiftTransferId, params, RequestOptions.none()) + + /** @see approve */ + fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see approve */ + fun approve( + params: SwiftTransferApproveParams + ): CompletableFuture> = + approve(params, RequestOptions.none()) + + /** @see approve */ + fun approve( + swiftTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + approve(swiftTransferId, SwiftTransferApproveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /swift_transfers/{swift_transfer_id}/cancel`, but + * is otherwise the same as [SwiftTransferServiceAsync.cancel]. + */ + fun cancel(swiftTransferId: String): CompletableFuture> = + cancel(swiftTransferId, SwiftTransferCancelParams.none()) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + ): CompletableFuture> = + cancel(swiftTransferId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: SwiftTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: SwiftTransferCancelParams + ): CompletableFuture> = cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(swiftTransferId, SwiftTransferCancelParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncImpl.kt new file mode 100644 index 000000000..3d6563662 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncImpl.kt @@ -0,0 +1,261 @@ +// 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.swifttransfers.SwiftTransfer +import com.increase.api.models.swifttransfers.SwiftTransferApproveParams +import com.increase.api.models.swifttransfers.SwiftTransferCancelParams +import com.increase.api.models.swifttransfers.SwiftTransferCreateParams +import com.increase.api.models.swifttransfers.SwiftTransferListPageAsync +import com.increase.api.models.swifttransfers.SwiftTransferListPageResponse +import com.increase.api.models.swifttransfers.SwiftTransferListParams +import com.increase.api.models.swifttransfers.SwiftTransferRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SwiftTransferServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SwiftTransferServiceAsync { + + private val withRawResponse: SwiftTransferServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SwiftTransferServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SwiftTransferServiceAsync = + SwiftTransferServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /swift_transfers + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: SwiftTransferRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /swift_transfers/{swift_transfer_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SwiftTransferListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /swift_transfers + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /swift_transfers/{swift_transfer_id}/approve + withRawResponse().approve(params, requestOptions).thenApply { it.parse() } + + override fun cancel( + params: SwiftTransferCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /swift_transfers/{swift_transfer_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SwiftTransferServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SwiftTransferServiceAsync.WithRawResponse = + SwiftTransferServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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: SwiftTransferRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("swiftTransferId", params.swiftTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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: SwiftTransferListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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 { + SwiftTransferListPageAsync.builder() + .service(SwiftTransferServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val approveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("swiftTransferId", params.swiftTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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: SwiftTransferCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("swiftTransferId", params.swiftTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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/blocking/SwiftTransferService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferService.kt new file mode 100644 index 000000000..5945a0c85 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferService.kt @@ -0,0 +1,342 @@ +// 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.swifttransfers.SwiftTransfer +import com.increase.api.models.swifttransfers.SwiftTransferApproveParams +import com.increase.api.models.swifttransfers.SwiftTransferCancelParams +import com.increase.api.models.swifttransfers.SwiftTransferCreateParams +import com.increase.api.models.swifttransfers.SwiftTransferListPage +import com.increase.api.models.swifttransfers.SwiftTransferListParams +import com.increase.api.models.swifttransfers.SwiftTransferRetrieveParams +import java.util.function.Consumer + +interface SwiftTransferService { + + /** + * 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): SwiftTransferService + + /** Create a Swift Transfer */ + fun create(params: SwiftTransferCreateParams): SwiftTransfer = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer + + /** Retrieve a Swift Transfer */ + fun retrieve(swiftTransferId: String): SwiftTransfer = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer = + retrieve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + ): SwiftTransfer = retrieve(swiftTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SwiftTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer + + /** @see retrieve */ + fun retrieve(params: SwiftTransferRetrieveParams): SwiftTransfer = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(swiftTransferId: String, requestOptions: RequestOptions): SwiftTransfer = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none(), requestOptions) + + /** List Swift Transfers */ + fun list(): SwiftTransferListPage = list(SwiftTransferListParams.none()) + + /** @see list */ + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransferListPage + + /** @see list */ + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none() + ): SwiftTransferListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): SwiftTransferListPage = + list(SwiftTransferListParams.none(), requestOptions) + + /** Approve a Swift Transfer */ + fun approve(swiftTransferId: String): SwiftTransfer = + approve(swiftTransferId, SwiftTransferApproveParams.none()) + + /** @see approve */ + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer = + approve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see approve */ + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + ): SwiftTransfer = approve(swiftTransferId, params, RequestOptions.none()) + + /** @see approve */ + fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer + + /** @see approve */ + fun approve(params: SwiftTransferApproveParams): SwiftTransfer = + approve(params, RequestOptions.none()) + + /** @see approve */ + fun approve(swiftTransferId: String, requestOptions: RequestOptions): SwiftTransfer = + approve(swiftTransferId, SwiftTransferApproveParams.none(), requestOptions) + + /** Cancel a pending Swift Transfer */ + fun cancel(swiftTransferId: String): SwiftTransfer = + cancel(swiftTransferId, SwiftTransferCancelParams.none()) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer = + cancel(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + ): SwiftTransfer = cancel(swiftTransferId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: SwiftTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SwiftTransfer + + /** @see cancel */ + fun cancel(params: SwiftTransferCancelParams): SwiftTransfer = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(swiftTransferId: String, requestOptions: RequestOptions): SwiftTransfer = + cancel(swiftTransferId, SwiftTransferCancelParams.none(), requestOptions) + + /** + * A view of [SwiftTransferService] 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 + ): SwiftTransferService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /swift_transfers`, but is otherwise the same as + * [SwiftTransferService.create]. + */ + @MustBeClosed + fun create(params: SwiftTransferCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /swift_transfers/{swift_transfer_id}`, but is + * otherwise the same as [SwiftTransferService.retrieve]. + */ + @MustBeClosed + fun retrieve(swiftTransferId: String): HttpResponseFor = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + swiftTransferId: String, + params: SwiftTransferRetrieveParams = SwiftTransferRetrieveParams.none(), + ): HttpResponseFor = retrieve(swiftTransferId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: SwiftTransferRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: SwiftTransferRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + swiftTransferId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(swiftTransferId, SwiftTransferRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /swift_transfers`, but is otherwise the same as + * [SwiftTransferService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(SwiftTransferListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: SwiftTransferListParams = SwiftTransferListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(SwiftTransferListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /swift_transfers/{swift_transfer_id}/approve`, but + * is otherwise the same as [SwiftTransferService.approve]. + */ + @MustBeClosed + fun approve(swiftTransferId: String): HttpResponseFor = + approve(swiftTransferId, SwiftTransferApproveParams.none()) + + /** @see approve */ + @MustBeClosed + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + approve(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see approve */ + @MustBeClosed + fun approve( + swiftTransferId: String, + params: SwiftTransferApproveParams = SwiftTransferApproveParams.none(), + ): HttpResponseFor = approve(swiftTransferId, params, RequestOptions.none()) + + /** @see approve */ + @MustBeClosed + fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see approve */ + @MustBeClosed + fun approve(params: SwiftTransferApproveParams): HttpResponseFor = + approve(params, RequestOptions.none()) + + /** @see approve */ + @MustBeClosed + fun approve( + swiftTransferId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + approve(swiftTransferId, SwiftTransferApproveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /swift_transfers/{swift_transfer_id}/cancel`, but + * is otherwise the same as [SwiftTransferService.cancel]. + */ + @MustBeClosed + fun cancel(swiftTransferId: String): HttpResponseFor = + cancel(swiftTransferId, SwiftTransferCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().swiftTransferId(swiftTransferId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + swiftTransferId: String, + params: SwiftTransferCancelParams = SwiftTransferCancelParams.none(), + ): HttpResponseFor = cancel(swiftTransferId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: SwiftTransferCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: SwiftTransferCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + swiftTransferId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(swiftTransferId, SwiftTransferCancelParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferServiceImpl.kt new file mode 100644 index 000000000..cd4df481e --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SwiftTransferServiceImpl.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.swifttransfers.SwiftTransfer +import com.increase.api.models.swifttransfers.SwiftTransferApproveParams +import com.increase.api.models.swifttransfers.SwiftTransferCancelParams +import com.increase.api.models.swifttransfers.SwiftTransferCreateParams +import com.increase.api.models.swifttransfers.SwiftTransferListPage +import com.increase.api.models.swifttransfers.SwiftTransferListPageResponse +import com.increase.api.models.swifttransfers.SwiftTransferListParams +import com.increase.api.models.swifttransfers.SwiftTransferRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SwiftTransferServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SwiftTransferService { + + private val withRawResponse: SwiftTransferService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SwiftTransferService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SwiftTransferService = + SwiftTransferServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions, + ): SwiftTransfer = + // post /swift_transfers + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: SwiftTransferRetrieveParams, + requestOptions: RequestOptions, + ): SwiftTransfer = + // get /swift_transfers/{swift_transfer_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: SwiftTransferListParams, + requestOptions: RequestOptions, + ): SwiftTransferListPage = + // get /swift_transfers + withRawResponse().list(params, requestOptions).parse() + + override fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions, + ): SwiftTransfer = + // post /swift_transfers/{swift_transfer_id}/approve + withRawResponse().approve(params, requestOptions).parse() + + override fun cancel( + params: SwiftTransferCancelParams, + requestOptions: RequestOptions, + ): SwiftTransfer = + // post /swift_transfers/{swift_transfer_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SwiftTransferService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SwiftTransferService.WithRawResponse = + SwiftTransferServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SwiftTransferCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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: SwiftTransferRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("swiftTransferId", params.swiftTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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: SwiftTransferListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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 { + SwiftTransferListPage.builder() + .service(SwiftTransferServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val approveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun approve( + params: SwiftTransferApproveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("swiftTransferId", params.swiftTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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: SwiftTransferCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("swiftTransferId", params.swiftTransferId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("swift_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/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParamsTest.kt new file mode 100644 index 000000000..d3cadeb10 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferApproveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SwiftTransferApproveParamsTest { + + @Test + fun create() { + SwiftTransferApproveParams.builder() + .swiftTransferId("swift_transfer_29h21xkng03788zwd3fh") + .build() + } + + @Test + fun pathParams() { + val params = + SwiftTransferApproveParams.builder() + .swiftTransferId("swift_transfer_29h21xkng03788zwd3fh") + .build() + + assertThat(params._pathParam(0)).isEqualTo("swift_transfer_29h21xkng03788zwd3fh") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParamsTest.kt new file mode 100644 index 000000000..94adfc245 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCancelParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SwiftTransferCancelParamsTest { + + @Test + fun create() { + SwiftTransferCancelParams.builder() + .swiftTransferId("swift_transfer_29h21xkng03788zwd3fh") + .build() + } + + @Test + fun pathParams() { + val params = + SwiftTransferCancelParams.builder() + .swiftTransferId("swift_transfer_29h21xkng03788zwd3fh") + .build() + + assertThat(params._pathParam(0)).isEqualTo("swift_transfer_29h21xkng03788zwd3fh") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParamsTest.kt new file mode 100644 index 000000000..efff31d2d --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferCreateParamsTest.kt @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SwiftTransferCreateParamsTest { + + @Test + fun create() { + SwiftTransferCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .bankIdentificationCode("ECBFDEFFTPP") + .creditorAddress( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2("x") + .postalCode("60314") + .state("x") + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2("x") + .postalCode("10045") + .state("NY") + .build() + ) + .debtorName("National Phonograph Company") + .instructedAmount(100L) + .instructedCurrency(SwiftTransferCreateParams.InstructedCurrency.USD) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .unstructuredRemittanceInformation("New Swift transfer") + .requireApproval(true) + .routingNumber("x") + .build() + } + + @Test + fun body() { + val params = + SwiftTransferCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .bankIdentificationCode("ECBFDEFFTPP") + .creditorAddress( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2("x") + .postalCode("60314") + .state("x") + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2("x") + .postalCode("10045") + .state("NY") + .build() + ) + .debtorName("National Phonograph Company") + .instructedAmount(100L) + .instructedCurrency(SwiftTransferCreateParams.InstructedCurrency.USD) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .unstructuredRemittanceInformation("New Swift transfer") + .requireApproval(true) + .routingNumber("x") + .build() + + val body = params._body() + + assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(body.accountNumber()).isEqualTo("987654321") + assertThat(body.bankIdentificationCode()).isEqualTo("ECBFDEFFTPP") + assertThat(body.creditorAddress()) + .isEqualTo( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2("x") + .postalCode("60314") + .state("x") + .build() + ) + assertThat(body.creditorName()).isEqualTo("Ian Crease") + assertThat(body.debtorAddress()) + .isEqualTo( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2("x") + .postalCode("10045") + .state("NY") + .build() + ) + assertThat(body.debtorName()).isEqualTo("National Phonograph Company") + assertThat(body.instructedAmount()).isEqualTo(100L) + assertThat(body.instructedCurrency()) + .isEqualTo(SwiftTransferCreateParams.InstructedCurrency.USD) + assertThat(body.sourceAccountNumberId()).isEqualTo("account_number_v18nkfqm6afpsrvy82b2") + assertThat(body.unstructuredRemittanceInformation()).isEqualTo("New Swift transfer") + assertThat(body.requireApproval()).contains(true) + assertThat(body.routingNumber()).contains("x") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SwiftTransferCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .bankIdentificationCode("ECBFDEFFTPP") + .creditorAddress( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .build() + ) + .debtorName("National Phonograph Company") + .instructedAmount(100L) + .instructedCurrency(SwiftTransferCreateParams.InstructedCurrency.USD) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .unstructuredRemittanceInformation("New Swift transfer") + .build() + + val body = params._body() + + assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(body.accountNumber()).isEqualTo("987654321") + assertThat(body.bankIdentificationCode()).isEqualTo("ECBFDEFFTPP") + assertThat(body.creditorAddress()) + .isEqualTo( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .build() + ) + assertThat(body.creditorName()).isEqualTo("Ian Crease") + assertThat(body.debtorAddress()) + .isEqualTo( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .build() + ) + assertThat(body.debtorName()).isEqualTo("National Phonograph Company") + assertThat(body.instructedAmount()).isEqualTo(100L) + assertThat(body.instructedCurrency()) + .isEqualTo(SwiftTransferCreateParams.InstructedCurrency.USD) + assertThat(body.sourceAccountNumberId()).isEqualTo("account_number_v18nkfqm6afpsrvy82b2") + assertThat(body.unstructuredRemittanceInformation()).isEqualTo("New Swift transfer") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponseTest.kt new file mode 100644 index 000000000..2bd20834f --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListPageResponseTest.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 SwiftTransferListPageResponseTest { + + @Test + fun create() { + val swiftTransferListPageResponse = + SwiftTransferListPageResponse.builder() + .addData( + SwiftTransfer.builder() + .id("swift_transfer_29h21xkng03788zwd3fh") + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .amount(100L) + .bankIdentificationCode("ECBFDEFFTPP") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + SwiftTransfer.CreatedBy.builder() + .apiKey( + SwiftTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(SwiftTransfer.CreatedBy.Category.USER) + .oauthApplication( + SwiftTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + SwiftTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .creditorAddress( + SwiftTransfer.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2(null) + .postalCode("60314") + .state(null) + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransfer.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .postalCode("10045") + .state(null) + .build() + ) + .debtorName("National Phonograph Company") + .idempotencyKey(null) + .instructedAmount(100L) + .instructedCurrency(SwiftTransfer.InstructedCurrency.USD) + .pendingTransactionId("pending_transaction_k1sfetcau2qbvjbzgju4") + .routingNumber(null) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(SwiftTransfer.Status.INITIATED) + .transactionId("transaction_uyrp7fld2ium70oa7oi") + .type(SwiftTransfer.Type.SWIFT_TRANSFER) + .uniqueEndToEndTransactionReference("9a21e10a-7600-4a24-8ff3-2cbc5943c27a") + .unstructuredRemittanceInformation("Remittance information") + .build() + ) + .nextCursor("v57w5d") + .build() + + assertThat(swiftTransferListPageResponse.data()) + .containsExactly( + SwiftTransfer.builder() + .id("swift_transfer_29h21xkng03788zwd3fh") + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .amount(100L) + .bankIdentificationCode("ECBFDEFFTPP") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + SwiftTransfer.CreatedBy.builder() + .apiKey( + SwiftTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(SwiftTransfer.CreatedBy.Category.USER) + .oauthApplication( + SwiftTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + SwiftTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .creditorAddress( + SwiftTransfer.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2(null) + .postalCode("60314") + .state(null) + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransfer.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .postalCode("10045") + .state(null) + .build() + ) + .debtorName("National Phonograph Company") + .idempotencyKey(null) + .instructedAmount(100L) + .instructedCurrency(SwiftTransfer.InstructedCurrency.USD) + .pendingTransactionId("pending_transaction_k1sfetcau2qbvjbzgju4") + .routingNumber(null) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(SwiftTransfer.Status.INITIATED) + .transactionId("transaction_uyrp7fld2ium70oa7oi") + .type(SwiftTransfer.Type.SWIFT_TRANSFER) + .uniqueEndToEndTransactionReference("9a21e10a-7600-4a24-8ff3-2cbc5943c27a") + .unstructuredRemittanceInformation("Remittance information") + .build() + ) + assertThat(swiftTransferListPageResponse.nextCursor()).contains("v57w5d") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val swiftTransferListPageResponse = + SwiftTransferListPageResponse.builder() + .addData( + SwiftTransfer.builder() + .id("swift_transfer_29h21xkng03788zwd3fh") + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .amount(100L) + .bankIdentificationCode("ECBFDEFFTPP") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + SwiftTransfer.CreatedBy.builder() + .apiKey( + SwiftTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(SwiftTransfer.CreatedBy.Category.USER) + .oauthApplication( + SwiftTransfer.CreatedBy.OAuthApplication.builder() + .name("name") + .build() + ) + .user( + SwiftTransfer.CreatedBy.User.builder() + .email("user@example.com") + .build() + ) + .build() + ) + .creditorAddress( + SwiftTransfer.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2(null) + .postalCode("60314") + .state(null) + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransfer.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .postalCode("10045") + .state(null) + .build() + ) + .debtorName("National Phonograph Company") + .idempotencyKey(null) + .instructedAmount(100L) + .instructedCurrency(SwiftTransfer.InstructedCurrency.USD) + .pendingTransactionId("pending_transaction_k1sfetcau2qbvjbzgju4") + .routingNumber(null) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(SwiftTransfer.Status.INITIATED) + .transactionId("transaction_uyrp7fld2ium70oa7oi") + .type(SwiftTransfer.Type.SWIFT_TRANSFER) + .uniqueEndToEndTransactionReference("9a21e10a-7600-4a24-8ff3-2cbc5943c27a") + .unstructuredRemittanceInformation("Remittance information") + .build() + ) + .nextCursor("v57w5d") + .build() + + val roundtrippedSwiftTransferListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(swiftTransferListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSwiftTransferListPageResponse) + .isEqualTo(swiftTransferListPageResponse) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParamsTest.kt new file mode 100644 index 000000000..572db2f03 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferListParamsTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 SwiftTransferListParamsTest { + + @Test + fun create() { + SwiftTransferListParams.builder() + .accountId("account_id") + .createdAt( + SwiftTransferListParams.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( + SwiftTransferListParams.Status.builder() + .addIn(SwiftTransferListParams.Status.In.PENDING_APPROVAL) + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + SwiftTransferListParams.builder() + .accountId("account_id") + .createdAt( + SwiftTransferListParams.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( + SwiftTransferListParams.Status.builder() + .addIn(SwiftTransferListParams.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 = SwiftTransferListParams.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/swifttransfers/SwiftTransferRetrieveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferRetrieveParamsTest.kt new file mode 100644 index 000000000..46f70ab13 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SwiftTransferRetrieveParamsTest { + + @Test + fun create() { + SwiftTransferRetrieveParams.builder() + .swiftTransferId("swift_transfer_29h21xkng03788zwd3fh") + .build() + } + + @Test + fun pathParams() { + val params = + SwiftTransferRetrieveParams.builder() + .swiftTransferId("swift_transfer_29h21xkng03788zwd3fh") + .build() + + assertThat(params._pathParam(0)).isEqualTo("swift_transfer_29h21xkng03788zwd3fh") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferTest.kt new file mode 100644 index 000000000..64ca22ad1 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/swifttransfers/SwiftTransferTest.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.swifttransfers + +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 SwiftTransferTest { + + @Test + fun create() { + val swiftTransfer = + SwiftTransfer.builder() + .id("swift_transfer_29h21xkng03788zwd3fh") + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .amount(100L) + .bankIdentificationCode("ECBFDEFFTPP") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + SwiftTransfer.CreatedBy.builder() + .apiKey( + SwiftTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(SwiftTransfer.CreatedBy.Category.USER) + .oauthApplication( + SwiftTransfer.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user( + SwiftTransfer.CreatedBy.User.builder().email("user@example.com").build() + ) + .build() + ) + .creditorAddress( + SwiftTransfer.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2(null) + .postalCode("60314") + .state(null) + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransfer.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .postalCode("10045") + .state(null) + .build() + ) + .debtorName("National Phonograph Company") + .idempotencyKey(null) + .instructedAmount(100L) + .instructedCurrency(SwiftTransfer.InstructedCurrency.USD) + .pendingTransactionId("pending_transaction_k1sfetcau2qbvjbzgju4") + .routingNumber(null) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(SwiftTransfer.Status.INITIATED) + .transactionId("transaction_uyrp7fld2ium70oa7oi") + .type(SwiftTransfer.Type.SWIFT_TRANSFER) + .uniqueEndToEndTransactionReference("9a21e10a-7600-4a24-8ff3-2cbc5943c27a") + .unstructuredRemittanceInformation("Remittance information") + .build() + + assertThat(swiftTransfer.id()).isEqualTo("swift_transfer_29h21xkng03788zwd3fh") + assertThat(swiftTransfer.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") + assertThat(swiftTransfer.accountNumber()).isEqualTo("987654321") + assertThat(swiftTransfer.amount()).isEqualTo(100L) + assertThat(swiftTransfer.bankIdentificationCode()).isEqualTo("ECBFDEFFTPP") + assertThat(swiftTransfer.createdAt()) + .isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + assertThat(swiftTransfer.createdBy()) + .isEqualTo( + SwiftTransfer.CreatedBy.builder() + .apiKey( + SwiftTransfer.CreatedBy.ApiKey.builder().description("description").build() + ) + .category(SwiftTransfer.CreatedBy.Category.USER) + .oauthApplication( + SwiftTransfer.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user(SwiftTransfer.CreatedBy.User.builder().email("user@example.com").build()) + .build() + ) + assertThat(swiftTransfer.creditorAddress()) + .isEqualTo( + SwiftTransfer.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2(null) + .postalCode("60314") + .state(null) + .build() + ) + assertThat(swiftTransfer.creditorName()).isEqualTo("Ian Crease") + assertThat(swiftTransfer.debtorAddress()) + .isEqualTo( + SwiftTransfer.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .postalCode("10045") + .state(null) + .build() + ) + assertThat(swiftTransfer.debtorName()).isEqualTo("National Phonograph Company") + assertThat(swiftTransfer.idempotencyKey()).isEmpty + assertThat(swiftTransfer.instructedAmount()).isEqualTo(100L) + assertThat(swiftTransfer.instructedCurrency()) + .isEqualTo(SwiftTransfer.InstructedCurrency.USD) + assertThat(swiftTransfer.pendingTransactionId()) + .contains("pending_transaction_k1sfetcau2qbvjbzgju4") + assertThat(swiftTransfer.routingNumber()).isEmpty + assertThat(swiftTransfer.sourceAccountNumberId()) + .isEqualTo("account_number_v18nkfqm6afpsrvy82b2") + assertThat(swiftTransfer.status()).isEqualTo(SwiftTransfer.Status.INITIATED) + assertThat(swiftTransfer.transactionId()).contains("transaction_uyrp7fld2ium70oa7oi") + assertThat(swiftTransfer.type()).isEqualTo(SwiftTransfer.Type.SWIFT_TRANSFER) + assertThat(swiftTransfer.uniqueEndToEndTransactionReference()) + .isEqualTo("9a21e10a-7600-4a24-8ff3-2cbc5943c27a") + assertThat(swiftTransfer.unstructuredRemittanceInformation()) + .isEqualTo("Remittance information") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val swiftTransfer = + SwiftTransfer.builder() + .id("swift_transfer_29h21xkng03788zwd3fh") + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .amount(100L) + .bankIdentificationCode("ECBFDEFFTPP") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .createdBy( + SwiftTransfer.CreatedBy.builder() + .apiKey( + SwiftTransfer.CreatedBy.ApiKey.builder() + .description("description") + .build() + ) + .category(SwiftTransfer.CreatedBy.Category.USER) + .oauthApplication( + SwiftTransfer.CreatedBy.OAuthApplication.builder().name("name").build() + ) + .user( + SwiftTransfer.CreatedBy.User.builder().email("user@example.com").build() + ) + .build() + ) + .creditorAddress( + SwiftTransfer.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2(null) + .postalCode("60314") + .state(null) + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransfer.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .postalCode("10045") + .state(null) + .build() + ) + .debtorName("National Phonograph Company") + .idempotencyKey(null) + .instructedAmount(100L) + .instructedCurrency(SwiftTransfer.InstructedCurrency.USD) + .pendingTransactionId("pending_transaction_k1sfetcau2qbvjbzgju4") + .routingNumber(null) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .status(SwiftTransfer.Status.INITIATED) + .transactionId("transaction_uyrp7fld2ium70oa7oi") + .type(SwiftTransfer.Type.SWIFT_TRANSFER) + .uniqueEndToEndTransactionReference("9a21e10a-7600-4a24-8ff3-2cbc5943c27a") + .unstructuredRemittanceInformation("Remittance information") + .build() + + val roundtrippedSwiftTransfer = + jsonMapper.readValue( + jsonMapper.writeValueAsString(swiftTransfer), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSwiftTransfer).isEqualTo(swiftTransfer) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncTest.kt new file mode 100644 index 000000000..78fa9b59e --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/SwiftTransferServiceAsyncTest.kt @@ -0,0 +1,126 @@ +// 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.swifttransfers.SwiftTransferCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SwiftTransferServiceAsyncTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferServiceAsync = client.swiftTransfers() + + val swiftTransferFuture = + swiftTransferServiceAsync.create( + SwiftTransferCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .bankIdentificationCode("ECBFDEFFTPP") + .creditorAddress( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2("x") + .postalCode("60314") + .state("x") + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2("x") + .postalCode("10045") + .state("NY") + .build() + ) + .debtorName("National Phonograph Company") + .instructedAmount(100L) + .instructedCurrency(SwiftTransferCreateParams.InstructedCurrency.USD) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .unstructuredRemittanceInformation("New Swift transfer") + .requireApproval(true) + .routingNumber("x") + .build() + ) + + val swiftTransfer = swiftTransferFuture.get() + swiftTransfer.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferServiceAsync = client.swiftTransfers() + + val swiftTransferFuture = + swiftTransferServiceAsync.retrieve("swift_transfer_29h21xkng03788zwd3fh") + + val swiftTransfer = swiftTransferFuture.get() + swiftTransfer.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferServiceAsync = client.swiftTransfers() + + val pageFuture = swiftTransferServiceAsync.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 swiftTransferServiceAsync = client.swiftTransfers() + + val swiftTransferFuture = + swiftTransferServiceAsync.approve("swift_transfer_29h21xkng03788zwd3fh") + + val swiftTransfer = swiftTransferFuture.get() + swiftTransfer.validate() + } + + @Test + fun cancel() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferServiceAsync = client.swiftTransfers() + + val swiftTransferFuture = + swiftTransferServiceAsync.cancel("swift_transfer_29h21xkng03788zwd3fh") + + val swiftTransfer = swiftTransferFuture.get() + swiftTransfer.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/SwiftTransferServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/SwiftTransferServiceTest.kt new file mode 100644 index 000000000..45900fac0 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/SwiftTransferServiceTest.kt @@ -0,0 +1,118 @@ +// 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.swifttransfers.SwiftTransferCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SwiftTransferServiceTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferService = client.swiftTransfers() + + val swiftTransfer = + swiftTransferService.create( + SwiftTransferCreateParams.builder() + .accountId("account_in71c4amph0vgo2qllky") + .accountNumber("987654321") + .bankIdentificationCode("ECBFDEFFTPP") + .creditorAddress( + SwiftTransferCreateParams.CreditorAddress.builder() + .city("Frankfurt") + .country("DE") + .line1("Sonnemannstrasse 20") + .line2("x") + .postalCode("60314") + .state("x") + .build() + ) + .creditorName("Ian Crease") + .debtorAddress( + SwiftTransferCreateParams.DebtorAddress.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2("x") + .postalCode("10045") + .state("NY") + .build() + ) + .debtorName("National Phonograph Company") + .instructedAmount(100L) + .instructedCurrency(SwiftTransferCreateParams.InstructedCurrency.USD) + .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2") + .unstructuredRemittanceInformation("New Swift transfer") + .requireApproval(true) + .routingNumber("x") + .build() + ) + + swiftTransfer.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferService = client.swiftTransfers() + + val swiftTransfer = swiftTransferService.retrieve("swift_transfer_29h21xkng03788zwd3fh") + + swiftTransfer.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferService = client.swiftTransfers() + + val page = swiftTransferService.list() + + page.response().validate() + } + + @Test + fun approve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferService = client.swiftTransfers() + + val swiftTransfer = swiftTransferService.approve("swift_transfer_29h21xkng03788zwd3fh") + + swiftTransfer.validate() + } + + @Test + fun cancel() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val swiftTransferService = client.swiftTransfers() + + val swiftTransfer = swiftTransferService.cancel("swift_transfer_29h21xkng03788zwd3fh") + + swiftTransfer.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 d850038e5..296d3762c 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 @@ -76,6 +76,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.inboundRealTimePaymentsTransfers()).isNotNull() assertThat(client.fednowTransfers()).isNotNull() assertThat(client.inboundFednowTransfers()).isNotNull() + assertThat(client.swiftTransfers()).isNotNull() assertThat(client.checkDeposits()).isNotNull() assertThat(client.lockboxes()).isNotNull() assertThat(client.inboundMailItems()).isNotNull() From 95fada0c21274b74d7d0e4b387753933cfbcd691 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:27:14 +0000 Subject: [PATCH 2/2] release: 0.395.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1bb2c3312..02bfb399e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.394.0" + ".": "0.395.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a12b3f93..5f3be5af3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.395.0 (2026-01-08) + +Full Changelog: [v0.394.0...v0.395.0](https://github.com/Increase/increase-java/compare/v0.394.0...v0.395.0) + +### Features + +* **api:** api update ([ec66695](https://github.com/Increase/increase-java/commit/ec6669584ccc894314cf256a01e1ae78652c8aa6)) + ## 0.394.0 (2026-01-07) Full Changelog: [v0.393.0...v0.394.0](https://github.com/Increase/increase-java/compare/v0.393.0...v0.394.0) diff --git a/README.md b/README.md index 5a190ccee..bb2fa23ab 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.394.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.394.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.394.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.395.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.395.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.395.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.394.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.395.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.394.0") +implementation("com.increase.api:increase-java:0.395.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.394.0") com.increase.api increase-java - 0.394.0 + 0.395.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 2f890226f..c7fd06b53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.394.0" // x-release-please-version + version = "0.395.0" // x-release-please-version } subprojects {