diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a579a4349..97d8dbba5 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.99.0" + ".": "0.100.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 0ae331cd6..c01750cd7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 167 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-aa089e65735b8884f8cb391b39b9a0b295819e438bf976c98cc6150628ca5488.yml -openapi_spec_hash: 719876533d1496e9192c7a734a78c736 -config_hash: e9a46eb8acb9dc2c236f3e1958a1c4dd +configured_endpoints: 169 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-529662462c00af160f74568fe26dbe576cf1fdc9f427e11bb1939bd8acdcb43f.yml +openapi_spec_hash: a98631dfc66716d41ada4ddb199f7028 +config_hash: 2d501901f343d00775037fcec4121983 diff --git a/CHANGELOG.md b/CHANGELOG.md index df54f798b..dc96703a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.100.0 (2025-08-04) + +Full Changelog: [v0.99.0...v0.100.0](https://github.com/lithic-com/lithic-java/compare/v0.99.0...v0.100.0) + +### Features + +* **api:** adds new Account Activity API ([8c85abd](https://github.com/lithic-com/lithic-java/commit/8c85abda56d34fb424cb6343c3c7f96d0cd32b9a)) + ## 0.99.0 (2025-07-31) Full Changelog: [v0.98.0...v0.99.0](https://github.com/lithic-com/lithic-java/compare/v0.98.0...v0.99.0) diff --git a/README.md b/README.md index 247ce2123..ea643c48b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.99.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.99.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.99.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.100.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.100.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.100.0) @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc -The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.99.0). +The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.100.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.99.0") +implementation("com.lithic.api:lithic-java:0.100.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.99.0") com.lithic.api lithic-java - 0.99.0 + 0.100.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 5439db507..38798d539 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.99.0" // x-release-please-version + version = "0.100.0" // x-release-please-version } subprojects { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt index ababd62f1..19d433991 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt @@ -8,6 +8,7 @@ import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.models.ApiStatus import com.lithic.api.models.ClientApiStatusParams +import com.lithic.api.services.blocking.AccountActivityService import com.lithic.api.services.blocking.AccountHolderService import com.lithic.api.services.blocking.AccountService import com.lithic.api.services.blocking.AggregateBalanceService @@ -133,6 +134,8 @@ interface LithicClient { fun networkPrograms(): NetworkProgramService + fun accountActivity(): AccountActivityService + /** Status of api */ fun apiStatus(): ApiStatus = apiStatus(ClientApiStatusParams.none()) @@ -229,6 +232,8 @@ interface LithicClient { fun networkPrograms(): NetworkProgramService.WithRawResponse + fun accountActivity(): AccountActivityService.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/status`, but is otherwise the same as * [LithicClient.apiStatus]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt index 20cbe7005..63aa8975b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt @@ -7,6 +7,7 @@ import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.models.ApiStatus import com.lithic.api.models.ClientApiStatusParams +import com.lithic.api.services.async.AccountActivityServiceAsync import com.lithic.api.services.async.AccountHolderServiceAsync import com.lithic.api.services.async.AccountServiceAsync import com.lithic.api.services.async.AggregateBalanceServiceAsync @@ -133,6 +134,8 @@ interface LithicClientAsync { fun networkPrograms(): NetworkProgramServiceAsync + fun accountActivity(): AccountActivityServiceAsync + /** Status of api */ fun apiStatus(): CompletableFuture = apiStatus(ClientApiStatusParams.none()) @@ -232,6 +235,8 @@ interface LithicClientAsync { fun networkPrograms(): NetworkProgramServiceAsync.WithRawResponse + fun accountActivity(): AccountActivityServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/status`, but is otherwise the same as * [LithicClientAsync.apiStatus]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt index fa05a6755..173776d11 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt @@ -17,6 +17,8 @@ import com.lithic.api.core.http.parseable import com.lithic.api.core.prepareAsync import com.lithic.api.models.ApiStatus import com.lithic.api.models.ClientApiStatusParams +import com.lithic.api.services.async.AccountActivityServiceAsync +import com.lithic.api.services.async.AccountActivityServiceAsyncImpl import com.lithic.api.services.async.AccountHolderServiceAsync import com.lithic.api.services.async.AccountHolderServiceAsyncImpl import com.lithic.api.services.async.AccountServiceAsync @@ -207,6 +209,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl NetworkProgramServiceAsyncImpl(clientOptionsWithUserAgent) } + private val accountActivity: AccountActivityServiceAsync by lazy { + AccountActivityServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): LithicClient = sync override fun withRawResponse(): LithicClientAsync.WithRawResponse = withRawResponse @@ -273,6 +279,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun networkPrograms(): NetworkProgramServiceAsync = networkPrograms + override fun accountActivity(): AccountActivityServiceAsync = accountActivity + override fun apiStatus( params: ClientApiStatusParams, requestOptions: RequestOptions, @@ -401,6 +409,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl NetworkProgramServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val accountActivity: AccountActivityServiceAsync.WithRawResponse by lazy { + AccountActivityServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): LithicClientAsync.WithRawResponse = @@ -472,6 +484,9 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun networkPrograms(): NetworkProgramServiceAsync.WithRawResponse = networkPrograms + override fun accountActivity(): AccountActivityServiceAsync.WithRawResponse = + accountActivity + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt index 28a889f85..3be6e93bf 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt @@ -17,6 +17,8 @@ import com.lithic.api.core.http.parseable import com.lithic.api.core.prepare import com.lithic.api.models.ApiStatus import com.lithic.api.models.ClientApiStatusParams +import com.lithic.api.services.blocking.AccountActivityService +import com.lithic.api.services.blocking.AccountActivityServiceImpl import com.lithic.api.services.blocking.AccountHolderService import com.lithic.api.services.blocking.AccountHolderServiceImpl import com.lithic.api.services.blocking.AccountService @@ -190,6 +192,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient NetworkProgramServiceImpl(clientOptionsWithUserAgent) } + private val accountActivity: AccountActivityService by lazy { + AccountActivityServiceImpl(clientOptionsWithUserAgent) + } + override fun async(): LithicClientAsync = async override fun withRawResponse(): LithicClient.WithRawResponse = withRawResponse @@ -255,6 +261,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun networkPrograms(): NetworkProgramService = networkPrograms + override fun accountActivity(): AccountActivityService = accountActivity + override fun apiStatus( params: ClientApiStatusParams, requestOptions: RequestOptions, @@ -383,6 +391,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient NetworkProgramServiceImpl.WithRawResponseImpl(clientOptions) } + private val accountActivity: AccountActivityService.WithRawResponse by lazy { + AccountActivityServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): LithicClient.WithRawResponse = @@ -453,6 +465,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun networkPrograms(): NetworkProgramService.WithRawResponse = networkPrograms + override fun accountActivity(): AccountActivityService.WithRawResponse = accountActivity + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPage.kt new file mode 100644 index 000000000..3f32e1ddd --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPage.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.AutoPager +import com.lithic.api.core.Page +import com.lithic.api.core.checkRequired +import com.lithic.api.services.blocking.AccountActivityService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see AccountActivityService.list */ +class AccountActivityListPage +private constructor( + private val service: AccountActivityService, + private val params: AccountActivityListParams, + private val response: AccountActivityListPageResponse, +) : Page { + + /** + * Delegates to [AccountActivityListPageResponse], but gracefully handles missing data. + * + * @see AccountActivityListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [AccountActivityListPageResponse], but gracefully handles missing data. + * + * @see AccountActivityListPageResponse.hasMore + */ + fun hasMore(): Optional = response._hasMore().getOptional("has_more") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() + + fun nextPageParams(): AccountActivityListParams = + if (params.endingBefore().isPresent) { + params + .toBuilder() + .endingBefore( + items() + .first() + .accept( + object : AccountActivityListResponse.Visitor> { + override fun visitFinancialTransaction( + financialTransaction: + AccountActivityListResponse.FinancialTransaction + ): Optional = + financialTransaction._token().getOptional("token") + + override fun visitBookTransferTransaction( + bookTransferTransaction: + AccountActivityListResponse.BookTransferTransaction + ): Optional = + bookTransferTransaction._token().getOptional("token") + + override fun visitCardTransaction( + cardTransaction: AccountActivityListResponse.CardTransaction + ): Optional = cardTransaction._token().getOptional("token") + + override fun visitPaymentTransaction( + paymentTransaction: + AccountActivityListResponse.PaymentTransaction + ): Optional = + paymentTransaction._token().getOptional("token") + + override fun visitExternalPayment( + externalPayment: ExternalPayment + ): Optional = externalPayment._token().getOptional("token") + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ): Optional = + managementOperationTransaction._token().getOptional("token") + } + ) + ) + .build() + } else { + params + .toBuilder() + .startingAfter( + items() + .last() + .accept( + object : AccountActivityListResponse.Visitor> { + override fun visitFinancialTransaction( + financialTransaction: + AccountActivityListResponse.FinancialTransaction + ): Optional = + financialTransaction._token().getOptional("token") + + override fun visitBookTransferTransaction( + bookTransferTransaction: + AccountActivityListResponse.BookTransferTransaction + ): Optional = + bookTransferTransaction._token().getOptional("token") + + override fun visitCardTransaction( + cardTransaction: AccountActivityListResponse.CardTransaction + ): Optional = cardTransaction._token().getOptional("token") + + override fun visitPaymentTransaction( + paymentTransaction: + AccountActivityListResponse.PaymentTransaction + ): Optional = + paymentTransaction._token().getOptional("token") + + override fun visitExternalPayment( + externalPayment: ExternalPayment + ): Optional = externalPayment._token().getOptional("token") + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ): Optional = + managementOperationTransaction._token().getOptional("token") + } + ) + ) + .build() + } + + override fun nextPage(): AccountActivityListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): AccountActivityListParams = params + + /** The response that this page was parsed from. */ + fun response(): AccountActivityListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccountActivityListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountActivityListPage]. */ + class Builder internal constructor() { + + private var service: AccountActivityService? = null + private var params: AccountActivityListParams? = null + private var response: AccountActivityListPageResponse? = null + + @JvmSynthetic + internal fun from(accountActivityListPage: AccountActivityListPage) = apply { + service = accountActivityListPage.service + params = accountActivityListPage.params + response = accountActivityListPage.response + } + + fun service(service: AccountActivityService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: AccountActivityListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: AccountActivityListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [AccountActivityListPage]. + * + * 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(): AccountActivityListPage = + AccountActivityListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "AccountActivityListPage{service=$service, params=$params, response=$response}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPageAsync.kt new file mode 100644 index 000000000..e80c694b0 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPageAsync.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.AutoPagerAsync +import com.lithic.api.core.PageAsync +import com.lithic.api.core.checkRequired +import com.lithic.api.services.async.AccountActivityServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see AccountActivityServiceAsync.list */ +class AccountActivityListPageAsync +private constructor( + private val service: AccountActivityServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: AccountActivityListParams, + private val response: AccountActivityListPageResponse, +) : PageAsync { + + /** + * Delegates to [AccountActivityListPageResponse], but gracefully handles missing data. + * + * @see AccountActivityListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [AccountActivityListPageResponse], but gracefully handles missing data. + * + * @see AccountActivityListPageResponse.hasMore + */ + fun hasMore(): Optional = response._hasMore().getOptional("has_more") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() + + fun nextPageParams(): AccountActivityListParams = + if (params.endingBefore().isPresent) { + params + .toBuilder() + .endingBefore( + items() + .first() + .accept( + object : AccountActivityListResponse.Visitor> { + override fun visitFinancialTransaction( + financialTransaction: + AccountActivityListResponse.FinancialTransaction + ): Optional = + financialTransaction._token().getOptional("token") + + override fun visitBookTransferTransaction( + bookTransferTransaction: + AccountActivityListResponse.BookTransferTransaction + ): Optional = + bookTransferTransaction._token().getOptional("token") + + override fun visitCardTransaction( + cardTransaction: AccountActivityListResponse.CardTransaction + ): Optional = cardTransaction._token().getOptional("token") + + override fun visitPaymentTransaction( + paymentTransaction: + AccountActivityListResponse.PaymentTransaction + ): Optional = + paymentTransaction._token().getOptional("token") + + override fun visitExternalPayment( + externalPayment: ExternalPayment + ): Optional = externalPayment._token().getOptional("token") + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ): Optional = + managementOperationTransaction._token().getOptional("token") + } + ) + ) + .build() + } else { + params + .toBuilder() + .startingAfter( + items() + .last() + .accept( + object : AccountActivityListResponse.Visitor> { + override fun visitFinancialTransaction( + financialTransaction: + AccountActivityListResponse.FinancialTransaction + ): Optional = + financialTransaction._token().getOptional("token") + + override fun visitBookTransferTransaction( + bookTransferTransaction: + AccountActivityListResponse.BookTransferTransaction + ): Optional = + bookTransferTransaction._token().getOptional("token") + + override fun visitCardTransaction( + cardTransaction: AccountActivityListResponse.CardTransaction + ): Optional = cardTransaction._token().getOptional("token") + + override fun visitPaymentTransaction( + paymentTransaction: + AccountActivityListResponse.PaymentTransaction + ): Optional = + paymentTransaction._token().getOptional("token") + + override fun visitExternalPayment( + externalPayment: ExternalPayment + ): Optional = externalPayment._token().getOptional("token") + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ): Optional = + managementOperationTransaction._token().getOptional("token") + } + ) + ) + .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(): AccountActivityListParams = params + + /** The response that this page was parsed from. */ + fun response(): AccountActivityListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccountActivityListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountActivityListPageAsync]. */ + class Builder internal constructor() { + + private var service: AccountActivityServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: AccountActivityListParams? = null + private var response: AccountActivityListPageResponse? = null + + @JvmSynthetic + internal fun from(accountActivityListPageAsync: AccountActivityListPageAsync) = apply { + service = accountActivityListPageAsync.service + streamHandlerExecutor = accountActivityListPageAsync.streamHandlerExecutor + params = accountActivityListPageAsync.params + response = accountActivityListPageAsync.response + } + + fun service(service: AccountActivityServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: AccountActivityListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: AccountActivityListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [AccountActivityListPageAsync]. + * + * 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(): AccountActivityListPageAsync = + AccountActivityListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + + override fun toString() = + "AccountActivityListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPageResponse.kt new file mode 100644 index 000000000..0f72a8019 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListPageResponse.kt @@ -0,0 +1,264 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +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.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkKnown +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A response containing a list of transactions */ +class AccountActivityListPageResponse +private constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + ) : this(data, hasMore, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional> = data.getOptional("data") + + /** + * Indicates if there are more transactions available for pagination + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasMore(): Optional = hasMore.getOptional("has_more") + + /** + * 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 [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + @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 + * [AccountActivityListPageResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountActivityListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accountActivityListPageResponse: AccountActivityListPageResponse) = + apply { + data = accountActivityListPageResponse.data.map { it.toMutableList() } + hasMore = accountActivityListPageResponse.hasMore + additionalProperties = + accountActivityListPageResponse.additionalProperties.toMutableMap() + } + + 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 [AccountActivityListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: AccountActivityListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** + * Alias for calling [addData] with + * `AccountActivityListResponse.ofFinancialTransaction(financialTransaction)`. + */ + fun addData(financialTransaction: AccountActivityListResponse.FinancialTransaction) = + addData(AccountActivityListResponse.ofFinancialTransaction(financialTransaction)) + + /** + * Alias for calling [addData] with + * `AccountActivityListResponse.ofBookTransferTransaction(bookTransferTransaction)`. + */ + fun addData(bookTransferTransaction: AccountActivityListResponse.BookTransferTransaction) = + addData(AccountActivityListResponse.ofBookTransferTransaction(bookTransferTransaction)) + + /** + * Alias for calling [addData] with + * `AccountActivityListResponse.ofCardTransaction(cardTransaction)`. + */ + fun addData(cardTransaction: AccountActivityListResponse.CardTransaction) = + addData(AccountActivityListResponse.ofCardTransaction(cardTransaction)) + + /** + * Alias for calling [addData] with + * `AccountActivityListResponse.ofPaymentTransaction(paymentTransaction)`. + */ + fun addData(paymentTransaction: AccountActivityListResponse.PaymentTransaction) = + addData(AccountActivityListResponse.ofPaymentTransaction(paymentTransaction)) + + /** + * Alias for calling [addData] with + * `AccountActivityListResponse.ofExternalPayment(externalPayment)`. + */ + fun addData(externalPayment: ExternalPayment) = + addData(AccountActivityListResponse.ofExternalPayment(externalPayment)) + + /** + * Alias for calling [addData] with + * `AccountActivityListResponse.ofManagementOperationTransaction(managementOperationTransaction)`. + */ + fun addData(managementOperationTransaction: ManagementOperationTransaction) = + addData( + AccountActivityListResponse.ofManagementOperationTransaction( + managementOperationTransaction + ) + ) + + /** Indicates if there are more transactions available for pagination */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + 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 [AccountActivityListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccountActivityListPageResponse = + AccountActivityListPageResponse( + (data ?: JsonMissing.of()).map { it.toImmutable() }, + hasMore, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccountActivityListPageResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.forEach { it.validate() } } + hasMore() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (hasMore.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityListPageResponse && data == other.data && hasMore == other.hasMore && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, hasMore, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountActivityListPageResponse{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt new file mode 100644 index 000000000..0cf2ccc86 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt @@ -0,0 +1,866 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.lithic.api.core.Enum +import com.lithic.api.core.JsonField +import com.lithic.api.core.Params +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a list of transactions across all public accounts. */ +class AccountActivityListParams +private constructor( + private val begin: OffsetDateTime?, + private val businessAccountToken: String?, + private val category: TransactionCategory?, + private val end: OffsetDateTime?, + private val endingBefore: String?, + private val financialAccountToken: String?, + private val pageSize: Long?, + private val result: List?, + private val startingAfter: String?, + private val status: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Date string in RFC 3339 format. Only entries created after the specified time will be + * included. UTC time zone. + */ + fun begin(): Optional = Optional.ofNullable(begin) + + /** Filter by business account token */ + fun businessAccountToken(): Optional = Optional.ofNullable(businessAccountToken) + + /** Filter by transaction category */ + fun category(): Optional = Optional.ofNullable(category) + + /** + * Date string in RFC 3339 format. Only entries created before the specified time will be + * included. UTC time zone. + */ + fun end(): Optional = Optional.ofNullable(end) + + /** + * A cursor representing an item's token before which a page of results should end. Used to + * retrieve the previous page of results before this item. + */ + fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + + /** Filter by financial account token */ + fun financialAccountToken(): Optional = Optional.ofNullable(financialAccountToken) + + /** Page size (for pagination). */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** Filter by transaction result */ + fun result(): Optional> = Optional.ofNullable(result) + + /** + * A cursor representing an item's token after which a page of results should begin. Used to + * retrieve the next page of results after this item. + */ + fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + + /** Filter by transaction status */ + 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(): AccountActivityListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AccountActivityListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountActivityListParams]. */ + class Builder internal constructor() { + + private var begin: OffsetDateTime? = null + private var businessAccountToken: String? = null + private var category: TransactionCategory? = null + private var end: OffsetDateTime? = null + private var endingBefore: String? = null + private var financialAccountToken: String? = null + private var pageSize: Long? = null + private var result: MutableList? = null + private var startingAfter: String? = null + private var status: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accountActivityListParams: AccountActivityListParams) = apply { + begin = accountActivityListParams.begin + businessAccountToken = accountActivityListParams.businessAccountToken + category = accountActivityListParams.category + end = accountActivityListParams.end + endingBefore = accountActivityListParams.endingBefore + financialAccountToken = accountActivityListParams.financialAccountToken + pageSize = accountActivityListParams.pageSize + result = accountActivityListParams.result?.toMutableList() + startingAfter = accountActivityListParams.startingAfter + status = accountActivityListParams.status?.toMutableList() + additionalHeaders = accountActivityListParams.additionalHeaders.toBuilder() + additionalQueryParams = accountActivityListParams.additionalQueryParams.toBuilder() + } + + /** + * Date string in RFC 3339 format. Only entries created after the specified time will be + * included. UTC time zone. + */ + fun begin(begin: OffsetDateTime?) = apply { this.begin = begin } + + /** Alias for calling [Builder.begin] with `begin.orElse(null)`. */ + fun begin(begin: Optional) = begin(begin.getOrNull()) + + /** Filter by business account token */ + fun businessAccountToken(businessAccountToken: String?) = apply { + this.businessAccountToken = businessAccountToken + } + + /** + * Alias for calling [Builder.businessAccountToken] with + * `businessAccountToken.orElse(null)`. + */ + fun businessAccountToken(businessAccountToken: Optional) = + businessAccountToken(businessAccountToken.getOrNull()) + + /** Filter by transaction category */ + fun category(category: TransactionCategory?) = apply { this.category = category } + + /** Alias for calling [Builder.category] with `category.orElse(null)`. */ + fun category(category: Optional) = category(category.getOrNull()) + + /** + * Date string in RFC 3339 format. Only entries created before the specified time will be + * included. UTC time zone. + */ + fun end(end: OffsetDateTime?) = apply { this.end = end } + + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ + fun end(end: Optional) = end(end.getOrNull()) + + /** + * A cursor representing an item's token before which a page of results should end. Used to + * retrieve the previous page of results before this item. + */ + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) + + /** Filter by financial account token */ + fun financialAccountToken(financialAccountToken: String?) = apply { + this.financialAccountToken = financialAccountToken + } + + /** + * Alias for calling [Builder.financialAccountToken] with + * `financialAccountToken.orElse(null)`. + */ + fun financialAccountToken(financialAccountToken: Optional) = + financialAccountToken(financialAccountToken.getOrNull()) + + /** Page size (for pagination). */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** Filter by transaction result */ + fun result(result: List?) = apply { this.result = result?.toMutableList() } + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional>) = result(result.getOrNull()) + + /** + * Adds a single [Result] to [Builder.result]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + this.result = (this.result ?: mutableListOf()).apply { add(result) } + } + + /** + * A cursor representing an item's token after which a page of results should begin. Used to + * retrieve the next page of results after this item. + */ + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) + + /** Filter by transaction status */ + fun status(status: List?) = apply { this.status = status?.toMutableList() } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional>) = status(status.getOrNull()) + + /** + * Adds a single [Status] to [Builder.status]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStatus(status: Status) = apply { + this.status = (this.status ?: mutableListOf()).apply { add(status) } + } + + 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 [AccountActivityListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccountActivityListParams = + AccountActivityListParams( + begin, + businessAccountToken, + category, + end, + endingBefore, + financialAccountToken, + pageSize, + result?.toImmutable(), + startingAfter, + status?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + begin?.let { put("begin", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + businessAccountToken?.let { put("business_account_token", it) } + category?.let { put("category", it.toString()) } + end?.let { put("end", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + endingBefore?.let { put("ending_before", it) } + financialAccountToken?.let { put("financial_account_token", it) } + pageSize?.let { put("page_size", it.toString()) } + result?.let { put("result", it.joinToString(",") { it.toString() }) } + startingAfter?.let { put("starting_after", it) } + status?.let { put("status", it.joinToString(",") { it.toString() }) } + putAll(additionalQueryParams) + } + .build() + + /** Filter by transaction category */ + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Result @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } + + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [Result]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Result] 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 { + APPROVED, + DECLINED, + /** An enum member indicating that [Result] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown Result: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Result && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + 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 { + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val EXPIRED = of("EXPIRED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val VOIDED = of("VOIDED") + + @JvmField val RETURNED = of("RETURNED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + DECLINED, + EXPIRED, + PENDING, + SETTLED, + VOIDED, + RETURNED, + REVERSED, + } + + /** + * 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 { + DECLINED, + EXPIRED, + PENDING, + SETTLED, + VOIDED, + RETURNED, + REVERSED, + /** 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) { + DECLINED -> Value.DECLINED + EXPIRED -> Value.EXPIRED + PENDING -> Value.PENDING + SETTLED -> Value.SETTLED + VOIDED -> Value.VOIDED + RETURNED -> Value.RETURNED + REVERSED -> Value.REVERSED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DECLINED -> Known.DECLINED + EXPIRED -> Known.EXPIRED + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + VOIDED -> Known.VOIDED + RETURNED -> Known.RETURNED + REVERSED -> Known.REVERSED + else -> throw LithicInvalidDataException("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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("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: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityListParams && begin == other.begin && businessAccountToken == other.businessAccountToken && category == other.category && end == other.end && endingBefore == other.endingBefore && financialAccountToken == other.financialAccountToken && pageSize == other.pageSize && result == other.result && startingAfter == other.startingAfter && status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(begin, businessAccountToken, category, end, endingBefore, financialAccountToken, pageSize, result, startingAfter, status, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AccountActivityListParams{begin=$begin, businessAccountToken=$businessAccountToken, category=$category, end=$end, endingBefore=$endingBefore, financialAccountToken=$financialAccountToken, pageSize=$pageSize, result=$result, startingAfter=$startingAfter, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt new file mode 100644 index 000000000..2f768d2ad --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt @@ -0,0 +1,8893 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +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.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response containing multiple transaction types */ +@JsonDeserialize(using = AccountActivityListResponse.Deserializer::class) +@JsonSerialize(using = AccountActivityListResponse.Serializer::class) +class AccountActivityListResponse +private constructor( + private val financialTransaction: FinancialTransaction? = null, + private val bookTransferTransaction: BookTransferTransaction? = null, + private val cardTransaction: CardTransaction? = null, + private val paymentTransaction: PaymentTransaction? = null, + private val externalPayment: ExternalPayment? = null, + private val managementOperationTransaction: ManagementOperationTransaction? = null, + private val _json: JsonValue? = null, +) { + + /** Financial transaction with inheritance from unified base transaction */ + fun financialTransaction(): Optional = + Optional.ofNullable(financialTransaction) + + /** Book transfer transaction */ + fun bookTransferTransaction(): Optional = + Optional.ofNullable(bookTransferTransaction) + + /** Base class for all transaction types in the ledger service */ + fun cardTransaction(): Optional = Optional.ofNullable(cardTransaction) + + /** Payment transaction */ + fun paymentTransaction(): Optional = Optional.ofNullable(paymentTransaction) + + fun externalPayment(): Optional = Optional.ofNullable(externalPayment) + + fun managementOperationTransaction(): Optional = + Optional.ofNullable(managementOperationTransaction) + + fun isFinancialTransaction(): Boolean = financialTransaction != null + + fun isBookTransferTransaction(): Boolean = bookTransferTransaction != null + + fun isCardTransaction(): Boolean = cardTransaction != null + + fun isPaymentTransaction(): Boolean = paymentTransaction != null + + fun isExternalPayment(): Boolean = externalPayment != null + + fun isManagementOperationTransaction(): Boolean = managementOperationTransaction != null + + /** Financial transaction with inheritance from unified base transaction */ + fun asFinancialTransaction(): FinancialTransaction = + financialTransaction.getOrThrow("financialTransaction") + + /** Book transfer transaction */ + fun asBookTransferTransaction(): BookTransferTransaction = + bookTransferTransaction.getOrThrow("bookTransferTransaction") + + /** Base class for all transaction types in the ledger service */ + fun asCardTransaction(): CardTransaction = cardTransaction.getOrThrow("cardTransaction") + + /** Payment transaction */ + fun asPaymentTransaction(): PaymentTransaction = + paymentTransaction.getOrThrow("paymentTransaction") + + fun asExternalPayment(): ExternalPayment = externalPayment.getOrThrow("externalPayment") + + fun asManagementOperationTransaction(): ManagementOperationTransaction = + managementOperationTransaction.getOrThrow("managementOperationTransaction") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + financialTransaction != null -> visitor.visitFinancialTransaction(financialTransaction) + bookTransferTransaction != null -> + visitor.visitBookTransferTransaction(bookTransferTransaction) + cardTransaction != null -> visitor.visitCardTransaction(cardTransaction) + paymentTransaction != null -> visitor.visitPaymentTransaction(paymentTransaction) + externalPayment != null -> visitor.visitExternalPayment(externalPayment) + managementOperationTransaction != null -> + visitor.visitManagementOperationTransaction(managementOperationTransaction) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AccountActivityListResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFinancialTransaction(financialTransaction: FinancialTransaction) { + financialTransaction.validate() + } + + override fun visitBookTransferTransaction( + bookTransferTransaction: BookTransferTransaction + ) { + bookTransferTransaction.validate() + } + + override fun visitCardTransaction(cardTransaction: CardTransaction) { + cardTransaction.validate() + } + + override fun visitPaymentTransaction(paymentTransaction: PaymentTransaction) { + paymentTransaction.validate() + } + + override fun visitExternalPayment(externalPayment: ExternalPayment) { + externalPayment.validate() + } + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ) { + managementOperationTransaction.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitFinancialTransaction(financialTransaction: FinancialTransaction) = + financialTransaction.validity() + + override fun visitBookTransferTransaction( + bookTransferTransaction: BookTransferTransaction + ) = bookTransferTransaction.validity() + + override fun visitCardTransaction(cardTransaction: CardTransaction) = + cardTransaction.validity() + + override fun visitPaymentTransaction(paymentTransaction: PaymentTransaction) = + paymentTransaction.validity() + + override fun visitExternalPayment(externalPayment: ExternalPayment) = + externalPayment.validity() + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ) = managementOperationTransaction.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityListResponse && financialTransaction == other.financialTransaction && bookTransferTransaction == other.bookTransferTransaction && cardTransaction == other.cardTransaction && paymentTransaction == other.paymentTransaction && externalPayment == other.externalPayment && managementOperationTransaction == other.managementOperationTransaction /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(financialTransaction, bookTransferTransaction, cardTransaction, paymentTransaction, externalPayment, managementOperationTransaction) /* spotless:on */ + + override fun toString(): String = + when { + financialTransaction != null -> + "AccountActivityListResponse{financialTransaction=$financialTransaction}" + bookTransferTransaction != null -> + "AccountActivityListResponse{bookTransferTransaction=$bookTransferTransaction}" + cardTransaction != null -> + "AccountActivityListResponse{cardTransaction=$cardTransaction}" + paymentTransaction != null -> + "AccountActivityListResponse{paymentTransaction=$paymentTransaction}" + externalPayment != null -> + "AccountActivityListResponse{externalPayment=$externalPayment}" + managementOperationTransaction != null -> + "AccountActivityListResponse{managementOperationTransaction=$managementOperationTransaction}" + _json != null -> "AccountActivityListResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AccountActivityListResponse") + } + + companion object { + + /** Financial transaction with inheritance from unified base transaction */ + @JvmStatic + fun ofFinancialTransaction(financialTransaction: FinancialTransaction) = + AccountActivityListResponse(financialTransaction = financialTransaction) + + /** Book transfer transaction */ + @JvmStatic + fun ofBookTransferTransaction(bookTransferTransaction: BookTransferTransaction) = + AccountActivityListResponse(bookTransferTransaction = bookTransferTransaction) + + /** Base class for all transaction types in the ledger service */ + @JvmStatic + fun ofCardTransaction(cardTransaction: CardTransaction) = + AccountActivityListResponse(cardTransaction = cardTransaction) + + /** Payment transaction */ + @JvmStatic + fun ofPaymentTransaction(paymentTransaction: PaymentTransaction) = + AccountActivityListResponse(paymentTransaction = paymentTransaction) + + @JvmStatic + fun ofExternalPayment(externalPayment: ExternalPayment) = + AccountActivityListResponse(externalPayment = externalPayment) + + @JvmStatic + fun ofManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ) = + AccountActivityListResponse( + managementOperationTransaction = managementOperationTransaction + ) + } + + /** + * An interface that defines how to map each variant of [AccountActivityListResponse] to a value + * of type [T]. + */ + interface Visitor { + + /** Financial transaction with inheritance from unified base transaction */ + fun visitFinancialTransaction(financialTransaction: FinancialTransaction): T + + /** Book transfer transaction */ + fun visitBookTransferTransaction(bookTransferTransaction: BookTransferTransaction): T + + /** Base class for all transaction types in the ledger service */ + fun visitCardTransaction(cardTransaction: CardTransaction): T + + /** Payment transaction */ + fun visitPaymentTransaction(paymentTransaction: PaymentTransaction): T + + fun visitExternalPayment(externalPayment: ExternalPayment): T + + fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ): T + + /** + * Maps an unknown variant of [AccountActivityListResponse] to a value of type [T]. + * + * An instance of [AccountActivityListResponse] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AccountActivityListResponse: $json") + } + } + + internal class Deserializer : + BaseDeserializer(AccountActivityListResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AccountActivityListResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityListResponse(financialTransaction = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityListResponse(bookTransferTransaction = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityListResponse(cardTransaction = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityListResponse(paymentTransaction = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityListResponse(externalPayment = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + AccountActivityListResponse( + managementOperationTransaction = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> AccountActivityListResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(AccountActivityListResponse::class) { + + override fun serialize( + value: AccountActivityListResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.financialTransaction != null -> + generator.writeObject(value.financialTransaction) + value.bookTransferTransaction != null -> + generator.writeObject(value.bookTransferTransaction) + value.cardTransaction != null -> generator.writeObject(value.cardTransaction) + value.paymentTransaction != null -> generator.writeObject(value.paymentTransaction) + value.externalPayment != null -> generator.writeObject(value.externalPayment) + value.managementOperationTransaction != null -> + generator.writeObject(value.managementOperationTransaction) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AccountActivityListResponse") + } + } + } + + /** Financial transaction with inheritance from unified base transaction */ + class FinancialTransaction + private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + descriptor, + events, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + status, + updated, + mutableMapOf(), + ) + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * Transaction category + * + * @throws LithicInvalidDataException 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(): TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * Currency of the transaction, represented in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Transaction descriptor + * + * @throws LithicInvalidDataException 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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * List of transaction events + * + * @throws LithicInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Financial account token associated with the transaction + * + * @throws LithicInvalidDataException 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 financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Pending amount in cents + * + * @throws LithicInvalidDataException 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 pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * Transaction result + * + * @throws LithicInvalidDataException 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 result(): TransactionResult = result.getRequired("result") + + /** + * Settled amount in cents + * + * @throws LithicInvalidDataException 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 settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException 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(): TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * 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 [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @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 [FinancialTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .family() + * .financialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FinancialTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var financialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(financialTransaction: FinancialTransaction) = apply { + token = financialTransaction.token + category = financialTransaction.category + created = financialTransaction.created + currency = financialTransaction.currency + descriptor = financialTransaction.descriptor + events = financialTransaction.events.map { it.toMutableList() } + family = financialTransaction.family + financialAccountToken = financialTransaction.financialAccountToken + pendingAmount = financialTransaction.pendingAmount + result = financialTransaction.result + settledAmount = financialTransaction.settledAmount + status = financialTransaction.status + updated = financialTransaction.updated + additionalProperties = financialTransaction.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Transaction category */ + fun category(category: TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [TransactionCategory] + * 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 + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Currency of the transaction, represented in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Transaction descriptor */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** List of transaction events */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Financial account token associated with the transaction */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Pending amount in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** Transaction result */ + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Settled amount in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] 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 } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + 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 [FinancialTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .family() + * .financialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FinancialTransaction = + FinancialTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("descriptor", descriptor), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("updated", updated), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FinancialTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + descriptor() + events() + family().validate() + financialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + /** Transaction category */ + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transaction result */ + class TransactionResult + @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] 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 { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionResult && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FinancialTransaction && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && events == other.events && family == other.family && financialAccountToken == other.financialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && updated == other.updated && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, events, family, financialAccountToken, pendingAmount, result, settledAmount, status, updated, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FinancialTransaction{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, events=$events, family=$family, financialAccountToken=$financialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, updated=$updated, additionalProperties=$additionalProperties}" + } + + /** Book transfer transaction */ + class BookTransferTransaction + private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val fromFinancialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val toFinancialAccountToken: JsonField, + private val updated: JsonField, + private val externalId: JsonField, + private val externalResource: JsonField, + private val transactionSeries: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fromFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("to_financial_account_token") + @ExcludeMissing + toFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, + result, + settledAmount, + status, + toFinancialAccountToken, + updated, + externalId, + externalResource, + transactionSeries, + mutableMapOf(), + ) + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException 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(): TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * Currency of the transaction in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * List of events associated with this book transfer + * + * @throws LithicInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Source account token + * + * @throws LithicInvalidDataException 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 fromFinancialAccountToken(): String = + fromFinancialAccountToken.getRequired("from_financial_account_token") + + /** + * The pending amount of the transaction in cents + * + * @throws LithicInvalidDataException 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 pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException 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 result(): TransactionResult = result.getRequired("result") + + /** + * The settled amount of the transaction in cents + * + * @throws LithicInvalidDataException 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 settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException 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(): TransactionStatus = status.getRequired("status") + + /** + * Destination account token + * + * @throws LithicInvalidDataException 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 toFinancialAccountToken(): String = + toFinancialAccountToken.getRequired("to_financial_account_token") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * External identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [fromFinancialAccountToken]. + * + * Unlike [fromFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fun _fromFinancialAccountToken(): JsonField = fromFinancialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * 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 [toFinancialAccountToken]. + * + * Unlike [toFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("to_financial_account_token") + @ExcludeMissing + fun _toFinancialAccountToken(): JsonField = toFinancialAccountToken + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + + @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 [BookTransferTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BookTransferTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var fromFinancialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var toFinancialAccountToken: JsonField? = null + private var updated: JsonField? = null + private var externalId: JsonField = JsonMissing.of() + private var externalResource: JsonField = JsonMissing.of() + private var transactionSeries: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bookTransferTransaction: BookTransferTransaction) = apply { + token = bookTransferTransaction.token + category = bookTransferTransaction.category + created = bookTransferTransaction.created + currency = bookTransferTransaction.currency + events = bookTransferTransaction.events.map { it.toMutableList() } + family = bookTransferTransaction.family + fromFinancialAccountToken = bookTransferTransaction.fromFinancialAccountToken + pendingAmount = bookTransferTransaction.pendingAmount + result = bookTransferTransaction.result + settledAmount = bookTransferTransaction.settledAmount + status = bookTransferTransaction.status + toFinancialAccountToken = bookTransferTransaction.toFinancialAccountToken + updated = bookTransferTransaction.updated + externalId = bookTransferTransaction.externalId + externalResource = bookTransferTransaction.externalResource + transactionSeries = bookTransferTransaction.transactionSeries + additionalProperties = bookTransferTransaction.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [TransactionCategory] + * 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 + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** List of events associated with this book transfer */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Source account token */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) + + /** + * Sets [Builder.fromFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.fromFinancialAccountToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: JsonField) = apply { + this.fromFinancialAccountToken = fromFinancialAccountToken + } + + /** The pending amount of the transaction in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** The settled amount of the transaction in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] 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 } + + /** Destination account token */ + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + + /** + * Sets [Builder.toFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.toFinancialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + this.toFinancialAccountToken = toFinancialAccountToken + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** External identifier for the transaction */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** + * Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. + */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed + * [ExternalResource] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + + fun transactionSeries(transactionSeries: TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** + * Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. + */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [TransactionSeries] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transactionSeries(transactionSeries: JsonField) = apply { + this.transactionSeries = transactionSeries + } + + 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 [BookTransferTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BookTransferTransaction = + BookTransferTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("toFinancialAccountToken", toFinancialAccountToken), + checkRequired("updated", updated), + externalId, + externalResource, + transactionSeries, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BookTransferTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + events() + family().validate() + fromFinancialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + toFinancialAccountToken() + updated() + externalId() + externalResource().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (fromFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (toFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionResult + @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] 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 { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionResult && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionSeries + private constructor( + private val relatedTransactionEventToken: JsonField, + private val relatedTransactionToken: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + relatedTransactionEventToken: JsonField = JsonMissing.of(), + @JsonProperty("related_transaction_token") + @ExcludeMissing + relatedTransactionToken: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(relatedTransactionEventToken, relatedTransactionToken, type, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun relatedTransactionEventToken(): Optional = + relatedTransactionEventToken.getOptional("related_transaction_event_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun relatedTransactionToken(): Optional = + relatedTransactionToken.getOptional("related_transaction_token") + + /** + * @throws LithicInvalidDataException 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(): String = type.getRequired("type") + + /** + * Returns the raw JSON value of [relatedTransactionEventToken]. + * + * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken + + /** + * Returns the raw JSON value of [relatedTransactionToken]. + * + * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("related_transaction_token") + @ExcludeMissing + fun _relatedTransactionToken(): JsonField = relatedTransactionToken + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TransactionSeries]. */ + class Builder internal constructor() { + + private var relatedTransactionEventToken: JsonField? = null + private var relatedTransactionToken: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transactionSeries: TransactionSeries) = apply { + relatedTransactionEventToken = transactionSeries.relatedTransactionEventToken + relatedTransactionToken = transactionSeries.relatedTransactionToken + type = transactionSeries.type + additionalProperties = transactionSeries.additionalProperties.toMutableMap() + } + + fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = + relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) + + /** + * Alias for calling [Builder.relatedTransactionEventToken] with + * `relatedTransactionEventToken.orElse(null)`. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: Optional) = + relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) + + /** + * Sets [Builder.relatedTransactionEventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedTransactionEventToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = + apply { + this.relatedTransactionEventToken = relatedTransactionEventToken + } + + fun relatedTransactionToken(relatedTransactionToken: String?) = + relatedTransactionToken(JsonField.ofNullable(relatedTransactionToken)) + + /** + * Alias for calling [Builder.relatedTransactionToken] with + * `relatedTransactionToken.orElse(null)`. + */ + fun relatedTransactionToken(relatedTransactionToken: Optional) = + relatedTransactionToken(relatedTransactionToken.getOrNull()) + + /** + * Sets [Builder.relatedTransactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedTransactionToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun relatedTransactionToken(relatedTransactionToken: JsonField) = apply { + this.relatedTransactionToken = relatedTransactionToken + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [TransactionSeries]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TransactionSeries = + TransactionSeries( + checkRequired("relatedTransactionEventToken", relatedTransactionEventToken), + checkRequired("relatedTransactionToken", relatedTransactionToken), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TransactionSeries = apply { + if (validated) { + return@apply + } + + relatedTransactionEventToken() + relatedTransactionToken() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (relatedTransactionEventToken.asKnown().isPresent) 1 else 0) + + (if (relatedTransactionToken.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionSeries && relatedTransactionEventToken == other.relatedTransactionEventToken && relatedTransactionToken == other.relatedTransactionToken && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(relatedTransactionEventToken, relatedTransactionToken, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BookTransferTransaction && token == other.token && category == other.category && created == other.created && currency == other.currency && events == other.events && family == other.family && fromFinancialAccountToken == other.fromFinancialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && toFinancialAccountToken == other.toFinancialAccountToken && updated == other.updated && externalId == other.externalId && externalResource == other.externalResource && transactionSeries == other.transactionSeries && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, events, family, fromFinancialAccountToken, pendingAmount, result, settledAmount, status, toFinancialAccountToken, updated, externalId, externalResource, transactionSeries, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BookTransferTransaction{token=$token, category=$category, created=$created, currency=$currency, events=$events, family=$family, fromFinancialAccountToken=$fromFinancialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, toFinancialAccountToken=$toFinancialAccountToken, updated=$updated, externalId=$externalId, externalResource=$externalResource, transactionSeries=$transactionSeries, additionalProperties=$additionalProperties}" + } + + /** Base class for all transaction types in the ledger service */ + class CardTransaction + private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val acquirerFee: JsonField, + private val acquirerReferenceNumber: JsonField, + private val amount: JsonField, + private val amounts: JsonField, + private val authorizationAmount: JsonField, + private val authorizationCode: JsonField, + private val avs: JsonField, + private val cardToken: JsonField, + private val cardholderAuthentication: JsonField, + private val created: JsonField, + private val merchant: JsonField, + private val merchantAmount: JsonField, + private val merchantAuthorizationAmount: JsonField, + private val merchantCurrency: JsonField, + private val network: JsonField, + private val networkRiskScore: JsonField, + private val pos: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val tokenInfo: JsonField, + private val updated: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_fee") + @ExcludeMissing + acquirerFee: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_reference_number") + @ExcludeMissing + acquirerReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("amounts") + @ExcludeMissing + amounts: JsonField = JsonMissing.of(), + @JsonProperty("authorization_amount") + @ExcludeMissing + authorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("authorization_code") + @ExcludeMissing + authorizationCode: JsonField = JsonMissing.of(), + @JsonProperty("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), + @JsonProperty("card_token") + @ExcludeMissing + cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_authentication") + @ExcludeMissing + cardholderAuthentication: JsonField = + JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("merchant") + @ExcludeMissing + merchant: JsonField = JsonMissing.of(), + @JsonProperty("merchant_amount") + @ExcludeMissing + merchantAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_authorization_amount") + @ExcludeMissing + merchantAuthorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_currency") + @ExcludeMissing + merchantCurrency: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("network_risk_score") + @ExcludeMissing + networkRiskScore: JsonField = JsonMissing.of(), + @JsonProperty("pos") @ExcludeMissing pos: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("token_info") + @ExcludeMissing + tokenInfo: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + acquirerFee, + acquirerReferenceNumber, + amount, + amounts, + authorizationAmount, + authorizationCode, + avs, + cardToken, + cardholderAuthentication, + created, + merchant, + merchantAmount, + merchantAuthorizationAmount, + merchantCurrency, + network, + networkRiskScore, + pos, + result, + settledAmount, + status, + tokenInfo, + updated, + events, + family, + mutableMapOf(), + ) + + fun toTransaction(): Transaction = + Transaction.builder() + .token(token) + .accountToken(accountToken) + .acquirerFee(acquirerFee) + .acquirerReferenceNumber(acquirerReferenceNumber) + .amount(amount) + .amounts(amounts) + .authorizationAmount(authorizationAmount) + .authorizationCode(authorizationCode) + .avs(avs) + .cardToken(cardToken) + .cardholderAuthentication(cardholderAuthentication) + .created(created) + .merchant(merchant) + .merchantAmount(merchantAmount) + .merchantAuthorizationAmount(merchantAuthorizationAmount) + .merchantCurrency(merchantCurrency) + .network(network) + .networkRiskScore(networkRiskScore) + .pos(pos) + .result(result) + .settledAmount(settledAmount) + .status(status) + .tokenInfo(tokenInfo) + .updated(updated) + .events(events) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * The token for the account associated with this transaction. + * + * @throws LithicInvalidDataException 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the + * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative + * value to indicate credited fees. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun acquirerFee(): Optional = acquirerFee.getOptional("acquirer_fee") + + /** + * Unique identifier assigned to a transaction by the acquirer that can be used in dispute + * and chargeback filing. This field has been deprecated in favor of the + * `acquirer_reference_number` that resides in the event-level `network_info`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(): Optional = + acquirerReferenceNumber.getOptional("acquirer_reference_number") + + /** + * When the transaction is pending, this represents the authorization amount of the + * transaction in the anticipated settlement currency. Once the transaction has settled, + * this field represents the settled amount in the settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") fun amount(): Long = amount.getRequired("amount") + + /** + * @throws LithicInvalidDataException 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 amounts(): Transaction.TransactionAmounts = amounts.getRequired("amounts") + + /** + * The authorization amount of the transaction in the anticipated settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun authorizationAmount(): Optional = + authorizationAmount.getOptional("authorization_amount") + + /** + * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with + * networks. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authorizationCode(): Optional = + authorizationCode.getOptional("authorization_code") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun avs(): Optional = avs.getOptional("avs") + + /** + * Token for the card used in this transaction. + * + * @throws LithicInvalidDataException 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 cardToken(): String = cardToken.getRequired("card_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderAuthentication(): Optional = + cardholderAuthentication.getOptional("cardholder_authentication") + + /** + * Date and time when the transaction first occurred. UTC time zone. + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * @throws LithicInvalidDataException 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 merchant(): Transaction.Merchant = merchant.getRequired("merchant") + + /** + * Analogous to the 'amount', but in the merchant currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantAmount(): Optional = merchantAmount.getOptional("merchant_amount") + + /** + * Analogous to the 'authorization_amount', but in the merchant currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(): Optional = + merchantAuthorizationAmount.getOptional("merchant_authorization_amount") + + /** + * 3-character alphabetic ISO 4217 code for the local currency of the transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantCurrency(): String = merchantCurrency.getRequired("merchant_currency") + + /** + * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine the + * network code from the upstream provider. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun network(): Optional = network.getOptional("network") + + /** + * Network-provided score assessing risk level associated with a given authorization. Scores + * are on a range of 0-999, with 0 representing the lowest risk and 999 representing the + * highest risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkRiskScore(): Optional = networkRiskScore.getOptional("network_risk_score") + + /** + * @throws LithicInvalidDataException 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 pos(): Transaction.Pos = pos.getRequired("pos") + + /** + * @throws LithicInvalidDataException 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 result(): Transaction.DeclineResult = result.getRequired("result") + + /** + * The settled amount of the transaction in the settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Status of the transaction. + * + * @throws LithicInvalidDataException 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(): Transaction.Status = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenInfo(): Optional = tokenInfo.getOptional("token_info") + + /** + * Date and time when the transaction last updated. UTC time zone. + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = events.getOptional("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [acquirerFee]. + * + * Unlike [acquirerFee], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("acquirer_fee") + @ExcludeMissing + fun _acquirerFee(): JsonField = acquirerFee + + /** + * Returns the raw JSON value of [acquirerReferenceNumber]. + * + * Unlike [acquirerReferenceNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("acquirer_reference_number") + @ExcludeMissing + fun _acquirerReferenceNumber(): JsonField = acquirerReferenceNumber + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [amounts]. + * + * Unlike [amounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amounts") + @ExcludeMissing + fun _amounts(): JsonField = amounts + + /** + * Returns the raw JSON value of [authorizationAmount]. + * + * Unlike [authorizationAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("authorization_amount") + @ExcludeMissing + fun _authorizationAmount(): JsonField = authorizationAmount + + /** + * Returns the raw JSON value of [authorizationCode]. + * + * Unlike [authorizationCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorization_code") + @ExcludeMissing + fun _authorizationCode(): JsonField = authorizationCode + + /** + * Returns the raw JSON value of [avs]. + * + * Unlike [avs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("avs") @ExcludeMissing fun _avs(): JsonField = avs + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [cardholderAuthentication]. + * + * Unlike [cardholderAuthentication], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_authentication") + @ExcludeMissing + fun _cardholderAuthentication(): JsonField = + cardholderAuthentication + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [merchant]. + * + * Unlike [merchant], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant") + @ExcludeMissing + fun _merchant(): JsonField = merchant + + /** + * Returns the raw JSON value of [merchantAmount]. + * + * Unlike [merchantAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_amount") + @ExcludeMissing + fun _merchantAmount(): JsonField = merchantAmount + + /** + * Returns the raw JSON value of [merchantAuthorizationAmount]. + * + * Unlike [merchantAuthorizationAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_authorization_amount") + @ExcludeMissing + fun _merchantAuthorizationAmount(): JsonField = merchantAuthorizationAmount + + /** + * Returns the raw JSON value of [merchantCurrency]. + * + * Unlike [merchantCurrency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_currency") + @ExcludeMissing + fun _merchantCurrency(): JsonField = merchantCurrency + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network") + @ExcludeMissing + fun _network(): JsonField = network + + /** + * Returns the raw JSON value of [networkRiskScore]. + * + * Unlike [networkRiskScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_risk_score") + @ExcludeMissing + fun _networkRiskScore(): JsonField = networkRiskScore + + /** + * Returns the raw JSON value of [pos]. + * + * Unlike [pos], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pos") @ExcludeMissing fun _pos(): JsonField = pos + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * 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 [tokenInfo]. + * + * Unlike [tokenInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token_info") + @ExcludeMissing + fun _tokenInfo(): JsonField = tokenInfo + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + @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 [CardTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .acquirerFee() + * .acquirerReferenceNumber() + * .amount() + * .amounts() + * .authorizationAmount() + * .authorizationCode() + * .avs() + * .cardToken() + * .cardholderAuthentication() + * .created() + * .merchant() + * .merchantAmount() + * .merchantAuthorizationAmount() + * .merchantCurrency() + * .network() + * .networkRiskScore() + * .pos() + * .result() + * .settledAmount() + * .status() + * .tokenInfo() + * .updated() + * .family() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var acquirerFee: JsonField? = null + private var acquirerReferenceNumber: JsonField? = null + private var amount: JsonField? = null + private var amounts: JsonField? = null + private var authorizationAmount: JsonField? = null + private var authorizationCode: JsonField? = null + private var avs: JsonField? = null + private var cardToken: JsonField? = null + private var cardholderAuthentication: JsonField? = + null + private var created: JsonField? = null + private var merchant: JsonField? = null + private var merchantAmount: JsonField? = null + private var merchantAuthorizationAmount: JsonField? = null + private var merchantCurrency: JsonField? = null + private var network: JsonField? = null + private var networkRiskScore: JsonField? = null + private var pos: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var tokenInfo: JsonField? = null + private var updated: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardTransaction: CardTransaction) = apply { + token = cardTransaction.token + accountToken = cardTransaction.accountToken + acquirerFee = cardTransaction.acquirerFee + acquirerReferenceNumber = cardTransaction.acquirerReferenceNumber + amount = cardTransaction.amount + amounts = cardTransaction.amounts + authorizationAmount = cardTransaction.authorizationAmount + authorizationCode = cardTransaction.authorizationCode + avs = cardTransaction.avs + cardToken = cardTransaction.cardToken + cardholderAuthentication = cardTransaction.cardholderAuthentication + created = cardTransaction.created + merchant = cardTransaction.merchant + merchantAmount = cardTransaction.merchantAmount + merchantAuthorizationAmount = cardTransaction.merchantAuthorizationAmount + merchantCurrency = cardTransaction.merchantCurrency + network = cardTransaction.network + networkRiskScore = cardTransaction.networkRiskScore + pos = cardTransaction.pos + result = cardTransaction.result + settledAmount = cardTransaction.settledAmount + status = cardTransaction.status + tokenInfo = cardTransaction.tokenInfo + updated = cardTransaction.updated + events = cardTransaction.events.map { it.toMutableList() } + family = cardTransaction.family + additionalProperties = cardTransaction.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The token for the account associated with this transaction. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of + * the currency. Will be zero if no fee is assessed. Rebates may be transmitted as a + * negative value to indicate credited fees. + */ + fun acquirerFee(acquirerFee: Long?) = acquirerFee(JsonField.ofNullable(acquirerFee)) + + /** + * Alias for [Builder.acquirerFee]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun acquirerFee(acquirerFee: Long) = acquirerFee(acquirerFee as Long?) + + /** Alias for calling [Builder.acquirerFee] with `acquirerFee.orElse(null)`. */ + fun acquirerFee(acquirerFee: Optional) = acquirerFee(acquirerFee.getOrNull()) + + /** + * Sets [Builder.acquirerFee] to an arbitrary JSON value. + * + * You should usually call [Builder.acquirerFee] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acquirerFee(acquirerFee: JsonField) = apply { this.acquirerFee = acquirerFee } + + /** + * Unique identifier assigned to a transaction by the acquirer that can be used in + * dispute and chargeback filing. This field has been deprecated in favor of the + * `acquirer_reference_number` that resides in the event-level `network_info`. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: String?) = + acquirerReferenceNumber(JsonField.ofNullable(acquirerReferenceNumber)) + + /** + * Alias for calling [Builder.acquirerReferenceNumber] with + * `acquirerReferenceNumber.orElse(null)`. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: Optional) = + acquirerReferenceNumber(acquirerReferenceNumber.getOrNull()) + + /** + * Sets [Builder.acquirerReferenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.acquirerReferenceNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: JsonField) = apply { + this.acquirerReferenceNumber = acquirerReferenceNumber + } + + /** + * When the transaction is pending, this represents the authorization amount of the + * transaction in the anticipated settlement currency. Once the transaction has settled, + * this field represents the settled amount in the settlement currency. + */ + @Deprecated("deprecated") 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. + */ + @Deprecated("deprecated") + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun amounts(amounts: Transaction.TransactionAmounts) = amounts(JsonField.of(amounts)) + + /** + * Sets [Builder.amounts] to an arbitrary JSON value. + * + * You should usually call [Builder.amounts] with a well-typed + * [Transaction.TransactionAmounts] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun amounts(amounts: JsonField) = apply { + this.amounts = amounts + } + + /** + * The authorization amount of the transaction in the anticipated settlement currency. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long?) = + authorizationAmount(JsonField.ofNullable(authorizationAmount)) + + /** + * Alias for [Builder.authorizationAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long) = + authorizationAmount(authorizationAmount as Long?) + + /** + * Alias for calling [Builder.authorizationAmount] with + * `authorizationAmount.orElse(null)`. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Optional) = + authorizationAmount(authorizationAmount.getOrNull()) + + /** + * Sets [Builder.authorizationAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: JsonField) = apply { + this.authorizationAmount = authorizationAmount + } + + /** + * A fixed-width 6-digit numeric identifier that can be used to identify a transaction + * with networks. + */ + fun authorizationCode(authorizationCode: String?) = + authorizationCode(JsonField.ofNullable(authorizationCode)) + + /** + * Alias for calling [Builder.authorizationCode] with `authorizationCode.orElse(null)`. + */ + fun authorizationCode(authorizationCode: Optional) = + authorizationCode(authorizationCode.getOrNull()) + + /** + * Sets [Builder.authorizationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorizationCode(authorizationCode: JsonField) = apply { + this.authorizationCode = authorizationCode + } + + fun avs(avs: Transaction.Avs?) = avs(JsonField.ofNullable(avs)) + + /** Alias for calling [Builder.avs] with `avs.orElse(null)`. */ + fun avs(avs: Optional) = avs(avs.getOrNull()) + + /** + * Sets [Builder.avs] to an arbitrary JSON value. + * + * You should usually call [Builder.avs] with a well-typed [Transaction.Avs] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun avs(avs: JsonField) = apply { this.avs = avs } + + /** Token for the card used in this transaction. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + fun cardholderAuthentication( + cardholderAuthentication: Transaction.CardholderAuthentication? + ) = cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + + /** + * Alias for calling [Builder.cardholderAuthentication] with + * `cardholderAuthentication.orElse(null)`. + */ + fun cardholderAuthentication( + cardholderAuthentication: Optional + ) = cardholderAuthentication(cardholderAuthentication.getOrNull()) + + /** + * Sets [Builder.cardholderAuthentication] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderAuthentication] with a well-typed + * [Transaction.CardholderAuthentication] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun cardholderAuthentication( + cardholderAuthentication: JsonField + ) = apply { this.cardholderAuthentication = cardholderAuthentication } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun merchant(merchant: Transaction.Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Transaction.Merchant] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun merchant(merchant: JsonField) = apply { + this.merchant = merchant + } + + /** Analogous to the 'amount', but in the merchant currency. */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long?) = + merchantAmount(JsonField.ofNullable(merchantAmount)) + + /** + * Alias for [Builder.merchantAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + + /** Alias for calling [Builder.merchantAmount] with `merchantAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Optional) = + merchantAmount(merchantAmount.getOrNull()) + + /** + * Sets [Builder.merchantAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: JsonField) = apply { + this.merchantAmount = merchantAmount + } + + /** Analogous to the 'authorization_amount', but in the merchant currency. */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long?) = + merchantAuthorizationAmount(JsonField.ofNullable(merchantAuthorizationAmount)) + + /** + * Alias for [Builder.merchantAuthorizationAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long) = + merchantAuthorizationAmount(merchantAuthorizationAmount as Long?) + + /** + * Alias for calling [Builder.merchantAuthorizationAmount] with + * `merchantAuthorizationAmount.orElse(null)`. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Optional) = + merchantAuthorizationAmount(merchantAuthorizationAmount.getOrNull()) + + /** + * Sets [Builder.merchantAuthorizationAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAuthorizationAmount] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: JsonField) = apply { + this.merchantAuthorizationAmount = merchantAuthorizationAmount + } + + /** 3-character alphabetic ISO 4217 code for the local currency of the transaction. */ + @Deprecated("deprecated") + fun merchantCurrency(merchantCurrency: String) = + merchantCurrency(JsonField.of(merchantCurrency)) + + /** + * Sets [Builder.merchantCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCurrency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun merchantCurrency(merchantCurrency: JsonField) = apply { + this.merchantCurrency = merchantCurrency + } + + /** + * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine + * the network code from the upstream provider. + */ + fun network(network: Transaction.Network?) = network(JsonField.ofNullable(network)) + + /** Alias for calling [Builder.network] with `network.orElse(null)`. */ + fun network(network: Optional) = network(network.getOrNull()) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [Transaction.Network] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun network(network: JsonField) = apply { this.network = network } + + /** + * Network-provided score assessing risk level associated with a given authorization. + * Scores are on a range of 0-999, with 0 representing the lowest risk and 999 + * representing the highest risk. For Visa transactions, where the raw score has a range + * of 0-99, Lithic will normalize the score by multiplying the raw score by 10x. + */ + fun networkRiskScore(networkRiskScore: Long?) = + networkRiskScore(JsonField.ofNullable(networkRiskScore)) + + /** + * Alias for [Builder.networkRiskScore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun networkRiskScore(networkRiskScore: Long) = + networkRiskScore(networkRiskScore as Long?) + + /** + * Alias for calling [Builder.networkRiskScore] with `networkRiskScore.orElse(null)`. + */ + fun networkRiskScore(networkRiskScore: Optional) = + networkRiskScore(networkRiskScore.getOrNull()) + + /** + * Sets [Builder.networkRiskScore] to an arbitrary JSON value. + * + * You should usually call [Builder.networkRiskScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkRiskScore(networkRiskScore: JsonField) = apply { + this.networkRiskScore = networkRiskScore + } + + fun pos(pos: Transaction.Pos) = pos(JsonField.of(pos)) + + /** + * Sets [Builder.pos] to an arbitrary JSON value. + * + * You should usually call [Builder.pos] with a well-typed [Transaction.Pos] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pos(pos: JsonField) = apply { this.pos = pos } + + fun result(result: Transaction.DeclineResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [Transaction.DeclineResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + /** The settled amount of the transaction in the settlement currency. */ + @Deprecated("deprecated") + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Status of the transaction. */ + fun status(status: Transaction.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Transaction.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 } + + fun tokenInfo(tokenInfo: Transaction.TokenInfo?) = + tokenInfo(JsonField.ofNullable(tokenInfo)) + + /** Alias for calling [Builder.tokenInfo] with `tokenInfo.orElse(null)`. */ + fun tokenInfo(tokenInfo: Optional) = + tokenInfo(tokenInfo.getOrNull()) + + /** + * Sets [Builder.tokenInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenInfo] with a well-typed [Transaction.TokenInfo] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tokenInfo(tokenInfo: JsonField) = apply { + this.tokenInfo = tokenInfo + } + + /** Date and time when the transaction last updated. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Transaction.TransactionEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Transaction.TransactionEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + 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 [CardTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .acquirerFee() + * .acquirerReferenceNumber() + * .amount() + * .amounts() + * .authorizationAmount() + * .authorizationCode() + * .avs() + * .cardToken() + * .cardholderAuthentication() + * .created() + * .merchant() + * .merchantAmount() + * .merchantAuthorizationAmount() + * .merchantCurrency() + * .network() + * .networkRiskScore() + * .pos() + * .result() + * .settledAmount() + * .status() + * .tokenInfo() + * .updated() + * .family() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTransaction = + CardTransaction( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("acquirerFee", acquirerFee), + checkRequired("acquirerReferenceNumber", acquirerReferenceNumber), + checkRequired("amount", amount), + checkRequired("amounts", amounts), + checkRequired("authorizationAmount", authorizationAmount), + checkRequired("authorizationCode", authorizationCode), + checkRequired("avs", avs), + checkRequired("cardToken", cardToken), + checkRequired("cardholderAuthentication", cardholderAuthentication), + checkRequired("created", created), + checkRequired("merchant", merchant), + checkRequired("merchantAmount", merchantAmount), + checkRequired("merchantAuthorizationAmount", merchantAuthorizationAmount), + checkRequired("merchantCurrency", merchantCurrency), + checkRequired("network", network), + checkRequired("networkRiskScore", networkRiskScore), + checkRequired("pos", pos), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("tokenInfo", tokenInfo), + checkRequired("updated", updated), + (events ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("family", family), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTransaction = apply { + if (validated) { + return@apply + } + + token() + accountToken() + acquirerFee() + acquirerReferenceNumber() + amount() + amounts().validate() + authorizationAmount() + authorizationCode() + avs().ifPresent { it.validate() } + cardToken() + cardholderAuthentication().ifPresent { it.validate() } + created() + merchant().validate() + merchantAmount() + merchantAuthorizationAmount() + merchantCurrency() + network().ifPresent { it.validate() } + networkRiskScore() + pos().validate() + result().validate() + settledAmount() + status().validate() + tokenInfo().ifPresent { it.validate() } + updated() + events().ifPresent { it.forEach { it.validate() } } + family().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (acquirerFee.asKnown().isPresent) 1 else 0) + + (if (acquirerReferenceNumber.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (amounts.asKnown().getOrNull()?.validity() ?: 0) + + (if (authorizationAmount.asKnown().isPresent) 1 else 0) + + (if (authorizationCode.asKnown().isPresent) 1 else 0) + + (avs.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (cardholderAuthentication.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (merchantAmount.asKnown().isPresent) 1 else 0) + + (if (merchantAuthorizationAmount.asKnown().isPresent) 1 else 0) + + (if (merchantCurrency.asKnown().isPresent) 1 else 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (networkRiskScore.asKnown().isPresent) 1 else 0) + + (pos.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (tokenInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CardTransaction && token == other.token && accountToken == other.accountToken && acquirerFee == other.acquirerFee && acquirerReferenceNumber == other.acquirerReferenceNumber && amount == other.amount && amounts == other.amounts && authorizationAmount == other.authorizationAmount && authorizationCode == other.authorizationCode && avs == other.avs && cardToken == other.cardToken && cardholderAuthentication == other.cardholderAuthentication && created == other.created && merchant == other.merchant && merchantAmount == other.merchantAmount && merchantAuthorizationAmount == other.merchantAuthorizationAmount && merchantCurrency == other.merchantCurrency && network == other.network && networkRiskScore == other.networkRiskScore && pos == other.pos && result == other.result && settledAmount == other.settledAmount && status == other.status && tokenInfo == other.tokenInfo && updated == other.updated && events == other.events && family == other.family && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, accountToken, acquirerFee, acquirerReferenceNumber, amount, amounts, authorizationAmount, authorizationCode, avs, cardToken, cardholderAuthentication, created, merchant, merchantAmount, merchantAuthorizationAmount, merchantCurrency, network, networkRiskScore, pos, result, settledAmount, status, tokenInfo, updated, events, family, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTransaction{token=$token, accountToken=$accountToken, acquirerFee=$acquirerFee, acquirerReferenceNumber=$acquirerReferenceNumber, amount=$amount, amounts=$amounts, authorizationAmount=$authorizationAmount, authorizationCode=$authorizationCode, avs=$avs, cardToken=$cardToken, cardholderAuthentication=$cardholderAuthentication, created=$created, merchant=$merchant, merchantAmount=$merchantAmount, merchantAuthorizationAmount=$merchantAuthorizationAmount, merchantCurrency=$merchantCurrency, network=$network, networkRiskScore=$networkRiskScore, pos=$pos, result=$result, settledAmount=$settledAmount, status=$status, tokenInfo=$tokenInfo, updated=$updated, events=$events, family=$family, additionalProperties=$additionalProperties}" + } + + /** Payment transaction */ + class PaymentTransaction + private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val descriptor: JsonField, + private val direction: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val method: JsonField, + private val methodAttributes: JsonField, + private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val source: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val currency: JsonField, + private val expectedReleaseDate: JsonField, + private val externalBankAccountToken: JsonField, + private val userDefinedId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), + @JsonProperty("method_attributes") + @ExcludeMissing + methodAttributes: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("expected_release_date") + @ExcludeMissing + expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_account_token") + @ExcludeMissing + externalBankAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + descriptor, + direction, + events, + family, + financialAccountToken, + method, + methodAttributes, + pendingAmount, + relatedAccountTokens, + result, + settledAmount, + source, + status, + updated, + currency, + expectedReleaseDate, + externalBankAccountToken, + userDefinedId, + mutableMapOf(), + ) + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * Transaction category + * + * @throws LithicInvalidDataException 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(): TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * Transaction descriptor + * + * @throws LithicInvalidDataException 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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * Transfer direction + * + * @throws LithicInvalidDataException 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 direction(): Direction = direction.getRequired("direction") + + /** + * List of transaction events + * + * @throws LithicInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Financial account token + * + * @throws LithicInvalidDataException 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 financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Transfer method + * + * @throws LithicInvalidDataException 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 method(): Method = method.getRequired("method") + + /** + * Method-specific attributes + * + * @throws LithicInvalidDataException 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 methodAttributes(): MethodAttributes = methodAttributes.getRequired("method_attributes") + + /** + * Pending amount in cents + * + * @throws LithicInvalidDataException 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 pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * Related account tokens for the transaction + * + * @throws LithicInvalidDataException 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 relatedAccountTokens(): RelatedAccountTokens = + relatedAccountTokens.getRequired("related_account_tokens") + + /** + * Transaction result + * + * @throws LithicInvalidDataException 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 result(): TransactionResult = result.getRequired("result") + + /** + * Settled amount in cents + * + * @throws LithicInvalidDataException 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 settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Transaction source + * + * @throws LithicInvalidDataException 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 source(): Source = source.getRequired("source") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException 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(): TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Currency of the transaction in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * Expected release date for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expectedReleaseDate(): Optional = + expectedReleaseDate.getOptional("expected_release_date") + + /** + * External bank account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalBankAccountToken(): Optional = + externalBankAccountToken.getOptional("external_bank_account_token") + + /** + * User-defined identifier + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [methodAttributes]. + * + * Unlike [methodAttributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * 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 [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [expectedReleaseDate]. + * + * Unlike [expectedReleaseDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("expected_release_date") + @ExcludeMissing + fun _expectedReleaseDate(): JsonField = expectedReleaseDate + + /** + * Returns the raw JSON value of [externalBankAccountToken]. + * + * Unlike [externalBankAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken(): JsonField = externalBankAccountToken + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + @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 [PaymentTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var expectedReleaseDate: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentTransaction: PaymentTransaction) = apply { + token = paymentTransaction.token + category = paymentTransaction.category + created = paymentTransaction.created + descriptor = paymentTransaction.descriptor + direction = paymentTransaction.direction + events = paymentTransaction.events.map { it.toMutableList() } + family = paymentTransaction.family + financialAccountToken = paymentTransaction.financialAccountToken + method = paymentTransaction.method + methodAttributes = paymentTransaction.methodAttributes + pendingAmount = paymentTransaction.pendingAmount + relatedAccountTokens = paymentTransaction.relatedAccountTokens + result = paymentTransaction.result + settledAmount = paymentTransaction.settledAmount + source = paymentTransaction.source + status = paymentTransaction.status + updated = paymentTransaction.updated + currency = paymentTransaction.currency + expectedReleaseDate = paymentTransaction.expectedReleaseDate + externalBankAccountToken = paymentTransaction.externalBankAccountToken + userDefinedId = paymentTransaction.userDefinedId + additionalProperties = paymentTransaction.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Transaction category */ + fun category(category: TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [TransactionCategory] + * 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 + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Transaction descriptor */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Transfer direction */ + fun direction(direction: Direction) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [Direction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + /** List of transaction events */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Financial account token */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Transfer method */ + fun method(method: Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** Method-specific attributes */ + fun methodAttributes(methodAttributes: MethodAttributes) = + methodAttributes(JsonField.of(methodAttributes)) + + /** + * Sets [Builder.methodAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.methodAttributes] with a well-typed + * [MethodAttributes] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun methodAttributes(methodAttributes: JsonField) = apply { + this.methodAttributes = methodAttributes + } + + /** Alias for calling [methodAttributes] with `MethodAttributes.ofAch(ach)`. */ + fun methodAttributes(ach: MethodAttributes.AchMethodAttributes) = + methodAttributes(MethodAttributes.ofAch(ach)) + + /** Alias for calling [methodAttributes] with `MethodAttributes.ofWire(wire)`. */ + fun methodAttributes(wire: MethodAttributes.WireMethodAttributes) = + methodAttributes(MethodAttributes.ofWire(wire)) + + /** Pending amount in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** Related account tokens for the transaction */ + fun relatedAccountTokens(relatedAccountTokens: RelatedAccountTokens) = + relatedAccountTokens(JsonField.of(relatedAccountTokens)) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [RelatedAccountTokens] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = + apply { + this.relatedAccountTokens = relatedAccountTokens + } + + /** Transaction result */ + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Settled amount in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Transaction source */ + fun source(source: Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] 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 } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Expected release date for the transaction */ + fun expectedReleaseDate(expectedReleaseDate: LocalDate?) = + expectedReleaseDate(JsonField.ofNullable(expectedReleaseDate)) + + /** + * Alias for calling [Builder.expectedReleaseDate] with + * `expectedReleaseDate.orElse(null)`. + */ + fun expectedReleaseDate(expectedReleaseDate: Optional) = + expectedReleaseDate(expectedReleaseDate.getOrNull()) + + /** + * Sets [Builder.expectedReleaseDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedReleaseDate] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun expectedReleaseDate(expectedReleaseDate: JsonField) = apply { + this.expectedReleaseDate = expectedReleaseDate + } + + /** External bank account token */ + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) + + /** + * Alias for calling [Builder.externalBankAccountToken] with + * `externalBankAccountToken.orElse(null)`. + */ + fun externalBankAccountToken(externalBankAccountToken: Optional) = + externalBankAccountToken(externalBankAccountToken.getOrNull()) + + /** + * Sets [Builder.externalBankAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + /** User-defined identifier */ + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + 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 [PaymentTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentTransaction = + PaymentTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("descriptor", descriptor), + checkRequired("direction", direction), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("method", method), + checkRequired("methodAttributes", methodAttributes), + checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("source", source), + checkRequired("status", status), + checkRequired("updated", updated), + currency, + expectedReleaseDate, + externalBankAccountToken, + userDefinedId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + descriptor() + direction().validate() + events() + family().validate() + financialAccountToken() + method().validate() + methodAttributes().validate() + pendingAmount() + relatedAccountTokens().validate() + result().validate() + settledAmount() + source().validate() + status().validate() + updated() + currency() + expectedReleaseDate() + externalBankAccountToken() + userDefinedId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (if (externalBankAccountToken.asKnown().isPresent) 1 else 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + /** Transaction category */ + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transfer direction */ + class Direction @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 CREDIT = of("CREDIT") + + @JvmField val DEBIT = of("DEBIT") + + @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) + } + + /** An enum containing [Direction]'s known values. */ + enum class Known { + CREDIT, + DEBIT, + } + + /** + * An enum containing [Direction]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Direction] 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 { + CREDIT, + DEBIT, + /** + * An enum member indicating that [Direction] 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) { + CREDIT -> Value.CREDIT + DEBIT -> Value.DEBIT + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREDIT -> Known.CREDIT + DEBIT -> Known.DEBIT + else -> throw LithicInvalidDataException("Unknown Direction: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Direction = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Direction && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transfer method */ + class Method @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 ACH_NEXT_DAY = of("ACH_NEXT_DAY") + + @JvmField val ACH_SAME_DAY = of("ACH_SAME_DAY") + + @JvmField val WIRE = of("WIRE") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + ACH_NEXT_DAY, + ACH_SAME_DAY, + WIRE, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] 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 { + ACH_NEXT_DAY, + ACH_SAME_DAY, + WIRE, + /** + * An enum member indicating that [Method] 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) { + ACH_NEXT_DAY -> Value.ACH_NEXT_DAY + ACH_SAME_DAY -> Value.ACH_SAME_DAY + WIRE -> Value.WIRE + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH_NEXT_DAY -> Known.ACH_NEXT_DAY + ACH_SAME_DAY -> Known.ACH_SAME_DAY + WIRE -> Known.WIRE + else -> throw LithicInvalidDataException("Unknown Method: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Method && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Method-specific attributes */ + @JsonDeserialize(using = MethodAttributes.Deserializer::class) + @JsonSerialize(using = MethodAttributes.Serializer::class) + class MethodAttributes + private constructor( + private val ach: AchMethodAttributes? = null, + private val wire: WireMethodAttributes? = null, + private val _json: JsonValue? = null, + ) { + + fun ach(): Optional = Optional.ofNullable(ach) + + fun wire(): Optional = Optional.ofNullable(wire) + + fun isAch(): Boolean = ach != null + + fun isWire(): Boolean = wire != null + + fun asAch(): AchMethodAttributes = ach.getOrThrow("ach") + + fun asWire(): WireMethodAttributes = wire.getOrThrow("wire") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + ach != null -> visitor.visitAch(ach) + wire != null -> visitor.visitWire(wire) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MethodAttributes = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAch(ach: AchMethodAttributes) { + ach.validate() + } + + override fun visitWire(wire: WireMethodAttributes) { + wire.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitAch(ach: AchMethodAttributes) = ach.validity() + + override fun visitWire(wire: WireMethodAttributes) = wire.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MethodAttributes && ach == other.ach && wire == other.wire /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(ach, wire) /* spotless:on */ + + override fun toString(): String = + when { + ach != null -> "MethodAttributes{ach=$ach}" + wire != null -> "MethodAttributes{wire=$wire}" + _json != null -> "MethodAttributes{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MethodAttributes") + } + + companion object { + + @JvmStatic fun ofAch(ach: AchMethodAttributes) = MethodAttributes(ach = ach) + + @JvmStatic fun ofWire(wire: WireMethodAttributes) = MethodAttributes(wire = wire) + } + + /** + * An interface that defines how to map each variant of [MethodAttributes] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAch(ach: AchMethodAttributes): T + + fun visitWire(wire: WireMethodAttributes): T + + /** + * Maps an unknown variant of [MethodAttributes] to a value of type [T]. + * + * An instance of [MethodAttributes] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown MethodAttributes: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MethodAttributes::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MethodAttributes { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MethodAttributes(ach = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MethodAttributes(wire = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> MethodAttributes(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MethodAttributes::class) { + + override fun serialize( + value: MethodAttributes, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.ach != null -> generator.writeObject(value.ach) + value.wire != null -> generator.writeObject(value.wire) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MethodAttributes") + } + } + } + + class AchMethodAttributes + private constructor( + private val secCode: JsonField, + private val addenda: JsonField, + private val companyId: JsonField, + private val receiptRoutingNumber: JsonField, + private val retries: JsonField, + private val returnReasonCode: JsonField, + private val traceNumbers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sec_code") + @ExcludeMissing + secCode: JsonField = JsonMissing.of(), + @JsonProperty("addenda") + @ExcludeMissing + addenda: JsonField = JsonMissing.of(), + @JsonProperty("company_id") + @ExcludeMissing + companyId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_routing_number") + @ExcludeMissing + receiptRoutingNumber: JsonField = JsonMissing.of(), + @JsonProperty("retries") + @ExcludeMissing + retries: JsonField = JsonMissing.of(), + @JsonProperty("return_reason_code") + @ExcludeMissing + returnReasonCode: JsonField = JsonMissing.of(), + @JsonProperty("trace_numbers") + @ExcludeMissing + traceNumbers: JsonField> = JsonMissing.of(), + ) : this( + secCode, + addenda, + companyId, + receiptRoutingNumber, + retries, + returnReasonCode, + traceNumbers, + mutableMapOf(), + ) + + /** + * SEC code for ACH transaction + * + * @throws LithicInvalidDataException 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 secCode(): SecCode = secCode.getRequired("sec_code") + + /** + * Addenda information + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addenda(): Optional = addenda.getOptional("addenda") + + /** + * Company ID for the ACH transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun companyId(): Optional = companyId.getOptional("company_id") + + /** + * Receipt routing number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun receiptRoutingNumber(): Optional = + receiptRoutingNumber.getOptional("receipt_routing_number") + + /** + * Number of retries attempted + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun retries(): Optional = retries.getOptional("retries") + + /** + * Return reason code if the transaction was returned + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnReasonCode(): Optional = + returnReasonCode.getOptional("return_reason_code") + + /** + * Trace numbers for the ACH transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceNumbers(): Optional> = + traceNumbers.getOptional("trace_numbers") + + /** + * Returns the raw JSON value of [secCode]. + * + * Unlike [secCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sec_code") + @ExcludeMissing + fun _secCode(): JsonField = secCode + + /** + * Returns the raw JSON value of [addenda]. + * + * Unlike [addenda], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("addenda") @ExcludeMissing fun _addenda(): JsonField = addenda + + /** + * Returns the raw JSON value of [companyId]. + * + * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId + + /** + * Returns the raw JSON value of [receiptRoutingNumber]. + * + * Unlike [receiptRoutingNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("receipt_routing_number") + @ExcludeMissing + fun _receiptRoutingNumber(): JsonField = receiptRoutingNumber + + /** + * Returns the raw JSON value of [retries]. + * + * Unlike [retries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("retries") @ExcludeMissing fun _retries(): JsonField = retries + + /** + * Returns the raw JSON value of [returnReasonCode]. + * + * Unlike [returnReasonCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_reason_code") + @ExcludeMissing + fun _returnReasonCode(): JsonField = returnReasonCode + + /** + * Returns the raw JSON value of [traceNumbers]. + * + * Unlike [traceNumbers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("trace_numbers") + @ExcludeMissing + fun _traceNumbers(): JsonField> = traceNumbers + + @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 + * [AchMethodAttributes]. + * + * The following fields are required: + * ```java + * .secCode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AchMethodAttributes]. */ + class Builder internal constructor() { + + private var secCode: JsonField? = null + private var addenda: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var receiptRoutingNumber: JsonField = JsonMissing.of() + private var retries: JsonField = JsonMissing.of() + private var returnReasonCode: JsonField = JsonMissing.of() + private var traceNumbers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(achMethodAttributes: AchMethodAttributes) = apply { + secCode = achMethodAttributes.secCode + addenda = achMethodAttributes.addenda + companyId = achMethodAttributes.companyId + receiptRoutingNumber = achMethodAttributes.receiptRoutingNumber + retries = achMethodAttributes.retries + returnReasonCode = achMethodAttributes.returnReasonCode + traceNumbers = achMethodAttributes.traceNumbers.map { it.toMutableList() } + additionalProperties = + achMethodAttributes.additionalProperties.toMutableMap() + } + + /** SEC code for ACH transaction */ + fun secCode(secCode: SecCode) = secCode(JsonField.of(secCode)) + + /** + * Sets [Builder.secCode] to an arbitrary JSON value. + * + * You should usually call [Builder.secCode] with a well-typed [SecCode] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun secCode(secCode: JsonField) = apply { this.secCode = secCode } + + /** Addenda information */ + fun addenda(addenda: String?) = addenda(JsonField.ofNullable(addenda)) + + /** Alias for calling [Builder.addenda] with `addenda.orElse(null)`. */ + fun addenda(addenda: Optional) = addenda(addenda.getOrNull()) + + /** + * Sets [Builder.addenda] to an arbitrary JSON value. + * + * You should usually call [Builder.addenda] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addenda(addenda: JsonField) = apply { this.addenda = addenda } + + /** Company ID for the ACH transaction */ + fun companyId(companyId: String?) = companyId(JsonField.ofNullable(companyId)) + + /** Alias for calling [Builder.companyId] with `companyId.orElse(null)`. */ + fun companyId(companyId: Optional) = companyId(companyId.getOrNull()) + + /** + * Sets [Builder.companyId] to an arbitrary JSON value. + * + * You should usually call [Builder.companyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun companyId(companyId: JsonField) = apply { + this.companyId = companyId + } + + /** Receipt routing number */ + fun receiptRoutingNumber(receiptRoutingNumber: String?) = + receiptRoutingNumber(JsonField.ofNullable(receiptRoutingNumber)) + + /** + * Alias for calling [Builder.receiptRoutingNumber] with + * `receiptRoutingNumber.orElse(null)`. + */ + fun receiptRoutingNumber(receiptRoutingNumber: Optional) = + receiptRoutingNumber(receiptRoutingNumber.getOrNull()) + + /** + * Sets [Builder.receiptRoutingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptRoutingNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receiptRoutingNumber(receiptRoutingNumber: JsonField) = apply { + this.receiptRoutingNumber = receiptRoutingNumber + } + + /** Number of retries attempted */ + fun retries(retries: Long?) = retries(JsonField.ofNullable(retries)) + + /** + * Alias for [Builder.retries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun retries(retries: Long) = retries(retries as Long?) + + /** Alias for calling [Builder.retries] with `retries.orElse(null)`. */ + fun retries(retries: Optional) = retries(retries.getOrNull()) + + /** + * Sets [Builder.retries] to an arbitrary JSON value. + * + * You should usually call [Builder.retries] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun retries(retries: JsonField) = apply { this.retries = retries } + + /** Return reason code if the transaction was returned */ + fun returnReasonCode(returnReasonCode: String?) = + returnReasonCode(JsonField.ofNullable(returnReasonCode)) + + /** + * Alias for calling [Builder.returnReasonCode] with + * `returnReasonCode.orElse(null)`. + */ + fun returnReasonCode(returnReasonCode: Optional) = + returnReasonCode(returnReasonCode.getOrNull()) + + /** + * Sets [Builder.returnReasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.returnReasonCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnReasonCode(returnReasonCode: JsonField) = apply { + this.returnReasonCode = returnReasonCode + } + + /** Trace numbers for the ACH transaction */ + fun traceNumbers(traceNumbers: List) = + traceNumbers(JsonField.of(traceNumbers)) + + /** + * Sets [Builder.traceNumbers] to an arbitrary JSON value. + * + * You should usually call [Builder.traceNumbers] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun traceNumbers(traceNumbers: JsonField>) = apply { + this.traceNumbers = traceNumbers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [traceNumbers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTraceNumber(traceNumber: String) = apply { + traceNumbers = + (traceNumbers ?: JsonField.of(mutableListOf())).also { + checkKnown("traceNumbers", it).add(traceNumber) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AchMethodAttributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .secCode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AchMethodAttributes = + AchMethodAttributes( + checkRequired("secCode", secCode), + addenda, + companyId, + receiptRoutingNumber, + retries, + returnReasonCode, + (traceNumbers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AchMethodAttributes = apply { + if (validated) { + return@apply + } + + secCode().validate() + addenda() + companyId() + receiptRoutingNumber() + retries() + returnReasonCode() + traceNumbers() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + (secCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (addenda.asKnown().isPresent) 1 else 0) + + (if (companyId.asKnown().isPresent) 1 else 0) + + (if (receiptRoutingNumber.asKnown().isPresent) 1 else 0) + + (if (retries.asKnown().isPresent) 1 else 0) + + (if (returnReasonCode.asKnown().isPresent) 1 else 0) + + (traceNumbers.asKnown().getOrNull()?.size ?: 0) + + /** SEC code for ACH transaction */ + class SecCode + @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 CCD = of("CCD") + + @JvmField val PPD = of("PPD") + + @JvmField val WEB = of("WEB") + + @JvmField val TEL = of("TEL") + + @JvmField val CIE = of("CIE") + + @JvmField val CTX = of("CTX") + + @JvmStatic fun of(value: String) = SecCode(JsonField.of(value)) + } + + /** An enum containing [SecCode]'s known values. */ + enum class Known { + CCD, + PPD, + WEB, + TEL, + CIE, + CTX, + } + + /** + * An enum containing [SecCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SecCode] 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 { + CCD, + PPD, + WEB, + TEL, + CIE, + CTX, + /** + * An enum member indicating that [SecCode] 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) { + CCD -> Value.CCD + PPD -> Value.PPD + WEB -> Value.WEB + TEL -> Value.TEL + CIE -> Value.CIE + CTX -> Value.CTX + 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 LithicInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CCD -> Known.CCD + PPD -> Known.PPD + WEB -> Known.WEB + TEL -> Known.TEL + CIE -> Known.CIE + CTX -> Known.CTX + else -> throw LithicInvalidDataException("Unknown SecCode: $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 LithicInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SecCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SecCode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AchMethodAttributes && secCode == other.secCode && addenda == other.addenda && companyId == other.companyId && receiptRoutingNumber == other.receiptRoutingNumber && retries == other.retries && returnReasonCode == other.returnReasonCode && traceNumbers == other.traceNumbers && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(secCode, addenda, companyId, receiptRoutingNumber, retries, returnReasonCode, traceNumbers, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AchMethodAttributes{secCode=$secCode, addenda=$addenda, companyId=$companyId, receiptRoutingNumber=$receiptRoutingNumber, retries=$retries, returnReasonCode=$returnReasonCode, traceNumbers=$traceNumbers, additionalProperties=$additionalProperties}" + } + + class WireMethodAttributes + private constructor( + private val wireTransferType: JsonField, + private val externalBankName: JsonField, + private val externalBankRoutingNumber: JsonField, + private val externalIndividualName: JsonField, + private val lithicBankName: JsonField, + private val lithicBankRoutingNumber: JsonField, + private val lithicIndividualName: JsonField, + private val previousTransfer: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("wire_transfer_type") + @ExcludeMissing + wireTransferType: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_name") + @ExcludeMissing + externalBankName: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_routing_number") + @ExcludeMissing + externalBankRoutingNumber: JsonField = JsonMissing.of(), + @JsonProperty("external_individual_name") + @ExcludeMissing + externalIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("lithic_bank_name") + @ExcludeMissing + lithicBankName: JsonField = JsonMissing.of(), + @JsonProperty("lithic_bank_routing_number") + @ExcludeMissing + lithicBankRoutingNumber: JsonField = JsonMissing.of(), + @JsonProperty("lithic_individual_name") + @ExcludeMissing + lithicIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("previous_transfer") + @ExcludeMissing + previousTransfer: JsonField = JsonMissing.of(), + ) : this( + wireTransferType, + externalBankName, + externalBankRoutingNumber, + externalIndividualName, + lithicBankName, + lithicBankRoutingNumber, + lithicIndividualName, + previousTransfer, + mutableMapOf(), + ) + + /** + * Type of wire transfer + * + * @throws LithicInvalidDataException 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 wireTransferType(): WireTransferType = + wireTransferType.getRequired("wire_transfer_type") + + /** + * External bank name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externalBankName(): Optional = + externalBankName.getOptional("external_bank_name") + + /** + * External bank routing number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externalBankRoutingNumber(): Optional = + externalBankRoutingNumber.getOptional("external_bank_routing_number") + + /** + * External individual name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externalIndividualName(): Optional = + externalIndividualName.getOptional("external_individual_name") + + /** + * Lithic bank name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lithicBankName(): Optional = + lithicBankName.getOptional("lithic_bank_name") + + /** + * Lithic bank routing number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lithicBankRoutingNumber(): Optional = + lithicBankRoutingNumber.getOptional("lithic_bank_routing_number") + + /** + * Lithic individual name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lithicIndividualName(): Optional = + lithicIndividualName.getOptional("lithic_individual_name") + + /** + * UUID of previous transfer if this is a retry + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun previousTransfer(): Optional = + previousTransfer.getOptional("previous_transfer") + + /** + * Returns the raw JSON value of [wireTransferType]. + * + * Unlike [wireTransferType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wire_transfer_type") + @ExcludeMissing + fun _wireTransferType(): JsonField = wireTransferType + + /** + * Returns the raw JSON value of [externalBankName]. + * + * Unlike [externalBankName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_bank_name") + @ExcludeMissing + fun _externalBankName(): JsonField = externalBankName + + /** + * Returns the raw JSON value of [externalBankRoutingNumber]. + * + * Unlike [externalBankRoutingNumber], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("external_bank_routing_number") + @ExcludeMissing + fun _externalBankRoutingNumber(): JsonField = externalBankRoutingNumber + + /** + * Returns the raw JSON value of [externalIndividualName]. + * + * Unlike [externalIndividualName], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("external_individual_name") + @ExcludeMissing + fun _externalIndividualName(): JsonField = externalIndividualName + + /** + * Returns the raw JSON value of [lithicBankName]. + * + * Unlike [lithicBankName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lithic_bank_name") + @ExcludeMissing + fun _lithicBankName(): JsonField = lithicBankName + + /** + * Returns the raw JSON value of [lithicBankRoutingNumber]. + * + * Unlike [lithicBankRoutingNumber], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lithic_bank_routing_number") + @ExcludeMissing + fun _lithicBankRoutingNumber(): JsonField = lithicBankRoutingNumber + + /** + * Returns the raw JSON value of [lithicIndividualName]. + * + * Unlike [lithicIndividualName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lithic_individual_name") + @ExcludeMissing + fun _lithicIndividualName(): JsonField = lithicIndividualName + + /** + * Returns the raw JSON value of [previousTransfer]. + * + * Unlike [previousTransfer], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previous_transfer") + @ExcludeMissing + fun _previousTransfer(): JsonField = previousTransfer + + @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 + * [WireMethodAttributes]. + * + * The following fields are required: + * ```java + * .wireTransferType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WireMethodAttributes]. */ + class Builder internal constructor() { + + private var wireTransferType: JsonField? = null + private var externalBankName: JsonField = JsonMissing.of() + private var externalBankRoutingNumber: JsonField = JsonMissing.of() + private var externalIndividualName: JsonField = JsonMissing.of() + private var lithicBankName: JsonField = JsonMissing.of() + private var lithicBankRoutingNumber: JsonField = JsonMissing.of() + private var lithicIndividualName: JsonField = JsonMissing.of() + private var previousTransfer: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(wireMethodAttributes: WireMethodAttributes) = apply { + wireTransferType = wireMethodAttributes.wireTransferType + externalBankName = wireMethodAttributes.externalBankName + externalBankRoutingNumber = wireMethodAttributes.externalBankRoutingNumber + externalIndividualName = wireMethodAttributes.externalIndividualName + lithicBankName = wireMethodAttributes.lithicBankName + lithicBankRoutingNumber = wireMethodAttributes.lithicBankRoutingNumber + lithicIndividualName = wireMethodAttributes.lithicIndividualName + previousTransfer = wireMethodAttributes.previousTransfer + additionalProperties = + wireMethodAttributes.additionalProperties.toMutableMap() + } + + /** Type of wire transfer */ + fun wireTransferType(wireTransferType: WireTransferType) = + wireTransferType(JsonField.of(wireTransferType)) + + /** + * Sets [Builder.wireTransferType] to an arbitrary JSON value. + * + * You should usually call [Builder.wireTransferType] with a well-typed + * [WireTransferType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun wireTransferType(wireTransferType: JsonField) = apply { + this.wireTransferType = wireTransferType + } + + /** External bank name */ + fun externalBankName(externalBankName: String?) = + externalBankName(JsonField.ofNullable(externalBankName)) + + /** + * Alias for calling [Builder.externalBankName] with + * `externalBankName.orElse(null)`. + */ + fun externalBankName(externalBankName: Optional) = + externalBankName(externalBankName.getOrNull()) + + /** + * Sets [Builder.externalBankName] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalBankName(externalBankName: JsonField) = apply { + this.externalBankName = externalBankName + } + + /** External bank routing number */ + fun externalBankRoutingNumber(externalBankRoutingNumber: String?) = + externalBankRoutingNumber(JsonField.ofNullable(externalBankRoutingNumber)) + + /** + * Alias for calling [Builder.externalBankRoutingNumber] with + * `externalBankRoutingNumber.orElse(null)`. + */ + fun externalBankRoutingNumber(externalBankRoutingNumber: Optional) = + externalBankRoutingNumber(externalBankRoutingNumber.getOrNull()) + + /** + * Sets [Builder.externalBankRoutingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankRoutingNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalBankRoutingNumber(externalBankRoutingNumber: JsonField) = + apply { + this.externalBankRoutingNumber = externalBankRoutingNumber + } + + /** External individual name */ + fun externalIndividualName(externalIndividualName: String?) = + externalIndividualName(JsonField.ofNullable(externalIndividualName)) + + /** + * Alias for calling [Builder.externalIndividualName] with + * `externalIndividualName.orElse(null)`. + */ + fun externalIndividualName(externalIndividualName: Optional) = + externalIndividualName(externalIndividualName.getOrNull()) + + /** + * Sets [Builder.externalIndividualName] to an arbitrary JSON value. + * + * You should usually call [Builder.externalIndividualName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalIndividualName(externalIndividualName: JsonField) = apply { + this.externalIndividualName = externalIndividualName + } + + /** Lithic bank name */ + fun lithicBankName(lithicBankName: String?) = + lithicBankName(JsonField.ofNullable(lithicBankName)) + + /** + * Alias for calling [Builder.lithicBankName] with + * `lithicBankName.orElse(null)`. + */ + fun lithicBankName(lithicBankName: Optional) = + lithicBankName(lithicBankName.getOrNull()) + + /** + * Sets [Builder.lithicBankName] to an arbitrary JSON value. + * + * You should usually call [Builder.lithicBankName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lithicBankName(lithicBankName: JsonField) = apply { + this.lithicBankName = lithicBankName + } + + /** Lithic bank routing number */ + fun lithicBankRoutingNumber(lithicBankRoutingNumber: String?) = + lithicBankRoutingNumber(JsonField.ofNullable(lithicBankRoutingNumber)) + + /** + * Alias for calling [Builder.lithicBankRoutingNumber] with + * `lithicBankRoutingNumber.orElse(null)`. + */ + fun lithicBankRoutingNumber(lithicBankRoutingNumber: Optional) = + lithicBankRoutingNumber(lithicBankRoutingNumber.getOrNull()) + + /** + * Sets [Builder.lithicBankRoutingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.lithicBankRoutingNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lithicBankRoutingNumber(lithicBankRoutingNumber: JsonField) = + apply { + this.lithicBankRoutingNumber = lithicBankRoutingNumber + } + + /** Lithic individual name */ + fun lithicIndividualName(lithicIndividualName: String?) = + lithicIndividualName(JsonField.ofNullable(lithicIndividualName)) + + /** + * Alias for calling [Builder.lithicIndividualName] with + * `lithicIndividualName.orElse(null)`. + */ + fun lithicIndividualName(lithicIndividualName: Optional) = + lithicIndividualName(lithicIndividualName.getOrNull()) + + /** + * Sets [Builder.lithicIndividualName] to an arbitrary JSON value. + * + * You should usually call [Builder.lithicIndividualName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lithicIndividualName(lithicIndividualName: JsonField) = apply { + this.lithicIndividualName = lithicIndividualName + } + + /** UUID of previous transfer if this is a retry */ + fun previousTransfer(previousTransfer: String?) = + previousTransfer(JsonField.ofNullable(previousTransfer)) + + /** + * Alias for calling [Builder.previousTransfer] with + * `previousTransfer.orElse(null)`. + */ + fun previousTransfer(previousTransfer: Optional) = + previousTransfer(previousTransfer.getOrNull()) + + /** + * Sets [Builder.previousTransfer] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTransfer] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTransfer(previousTransfer: JsonField) = apply { + this.previousTransfer = previousTransfer + } + + 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 [WireMethodAttributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .wireTransferType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WireMethodAttributes = + WireMethodAttributes( + checkRequired("wireTransferType", wireTransferType), + externalBankName, + externalBankRoutingNumber, + externalIndividualName, + lithicBankName, + lithicBankRoutingNumber, + lithicIndividualName, + previousTransfer, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WireMethodAttributes = apply { + if (validated) { + return@apply + } + + wireTransferType().validate() + externalBankName() + externalBankRoutingNumber() + externalIndividualName() + lithicBankName() + lithicBankRoutingNumber() + lithicIndividualName() + previousTransfer() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + (wireTransferType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalBankName.asKnown().isPresent) 1 else 0) + + (if (externalBankRoutingNumber.asKnown().isPresent) 1 else 0) + + (if (externalIndividualName.asKnown().isPresent) 1 else 0) + + (if (lithicBankName.asKnown().isPresent) 1 else 0) + + (if (lithicBankRoutingNumber.asKnown().isPresent) 1 else 0) + + (if (lithicIndividualName.asKnown().isPresent) 1 else 0) + + (if (previousTransfer.asKnown().isPresent) 1 else 0) + + /** Type of wire transfer */ + class WireTransferType + @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 FEDWIRE = of("FEDWIRE") + + @JvmField val SWIFT = of("SWIFT") + + @JvmStatic fun of(value: String) = WireTransferType(JsonField.of(value)) + } + + /** An enum containing [WireTransferType]'s known values. */ + enum class Known { + FEDWIRE, + SWIFT, + } + + /** + * An enum containing [WireTransferType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [WireTransferType] 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 { + FEDWIRE, + SWIFT, + /** + * An enum member indicating that [WireTransferType] 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) { + FEDWIRE -> Value.FEDWIRE + SWIFT -> Value.SWIFT + 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 LithicInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + FEDWIRE -> Known.FEDWIRE + SWIFT -> Known.SWIFT + else -> + throw LithicInvalidDataException("Unknown WireTransferType: $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 LithicInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): WireTransferType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is WireTransferType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is WireMethodAttributes && wireTransferType == other.wireTransferType && externalBankName == other.externalBankName && externalBankRoutingNumber == other.externalBankRoutingNumber && externalIndividualName == other.externalIndividualName && lithicBankName == other.lithicBankName && lithicBankRoutingNumber == other.lithicBankRoutingNumber && lithicIndividualName == other.lithicIndividualName && previousTransfer == other.previousTransfer && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(wireTransferType, externalBankName, externalBankRoutingNumber, externalIndividualName, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, previousTransfer, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WireMethodAttributes{wireTransferType=$wireTransferType, externalBankName=$externalBankName, externalBankRoutingNumber=$externalBankRoutingNumber, externalIndividualName=$externalIndividualName, lithicBankName=$lithicBankName, lithicBankRoutingNumber=$lithicBankRoutingNumber, lithicIndividualName=$lithicIndividualName, previousTransfer=$previousTransfer, additionalProperties=$additionalProperties}" + } + } + + /** Related account tokens for the transaction */ + class RelatedAccountTokens + private constructor( + private val accountToken: JsonField, + private val businessAccountToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("business_account_token") + @ExcludeMissing + businessAccountToken: JsonField = JsonMissing.of(), + ) : this(accountToken, businessAccountToken, mutableMapOf()) + + /** + * Globally unique identifier for the account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * Globally unique identifier for the business account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun businessAccountToken(): Optional = + businessAccountToken.getOptional("business_account_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [businessAccountToken]. + * + * Unlike [businessAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_account_token") + @ExcludeMissing + fun _businessAccountToken(): JsonField = businessAccountToken + + @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 [RelatedAccountTokens]. + * + * The following fields are required: + * ```java + * .accountToken() + * .businessAccountToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RelatedAccountTokens]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var businessAccountToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(relatedAccountTokens: RelatedAccountTokens) = apply { + accountToken = relatedAccountTokens.accountToken + businessAccountToken = relatedAccountTokens.businessAccountToken + additionalProperties = relatedAccountTokens.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the account */ + fun accountToken(accountToken: String?) = + accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = + accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Globally unique identifier for the business account */ + fun businessAccountToken(businessAccountToken: String?) = + businessAccountToken(JsonField.ofNullable(businessAccountToken)) + + /** + * Alias for calling [Builder.businessAccountToken] with + * `businessAccountToken.orElse(null)`. + */ + fun businessAccountToken(businessAccountToken: Optional) = + businessAccountToken(businessAccountToken.getOrNull()) + + /** + * Sets [Builder.businessAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.businessAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { + this.businessAccountToken = businessAccountToken + } + + 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 [RelatedAccountTokens]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .businessAccountToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RelatedAccountTokens = + RelatedAccountTokens( + checkRequired("accountToken", accountToken), + checkRequired("businessAccountToken", businessAccountToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RelatedAccountTokens = apply { + if (validated) { + return@apply + } + + accountToken() + businessAccountToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (accountToken.asKnown().isPresent) 1 else 0) + + (if (businessAccountToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RelatedAccountTokens && accountToken == other.accountToken && businessAccountToken == other.businessAccountToken && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accountToken, businessAccountToken, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RelatedAccountTokens{accountToken=$accountToken, businessAccountToken=$businessAccountToken, additionalProperties=$additionalProperties}" + } + + /** Transaction result */ + class TransactionResult + @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] 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 { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionResult && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transaction source */ + class Source @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 LITHIC = of("LITHIC") + + @JvmField val EXTERNAL = of("EXTERNAL") + + @JvmField val CUSTOMER = of("CUSTOMER") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + LITHIC, + EXTERNAL, + CUSTOMER, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + LITHIC, + EXTERNAL, + CUSTOMER, + /** + * An enum member indicating that [Source] 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) { + LITHIC -> Value.LITHIC + EXTERNAL -> Value.EXTERNAL + CUSTOMER -> Value.CUSTOMER + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LITHIC -> Known.LITHIC + EXTERNAL -> Known.EXTERNAL + CUSTOMER -> Known.CUSTOMER + else -> throw LithicInvalidDataException("Unknown Source: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentTransaction && token == other.token && category == other.category && created == other.created && descriptor == other.descriptor && direction == other.direction && events == other.events && family == other.family && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && relatedAccountTokens == other.relatedAccountTokens && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && currency == other.currency && expectedReleaseDate == other.expectedReleaseDate && externalBankAccountToken == other.externalBankAccountToken && userDefinedId == other.userDefinedId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, category, created, descriptor, direction, events, family, financialAccountToken, method, methodAttributes, pendingAmount, relatedAccountTokens, result, settledAmount, source, status, updated, currency, expectedReleaseDate, externalBankAccountToken, userDefinedId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentTransaction{token=$token, category=$category, created=$created, descriptor=$descriptor, direction=$direction, events=$events, family=$family, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, currency=$currency, expectedReleaseDate=$expectedReleaseDate, externalBankAccountToken=$externalBankAccountToken, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionParams.kt new file mode 100644 index 000000000..7b26c2a5d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionParams.kt @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.Params +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a single transaction */ +class AccountActivityRetrieveTransactionParams +private constructor( + private val transactionToken: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun transactionToken(): Optional = Optional.ofNullable(transactionToken) + + /** 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(): AccountActivityRetrieveTransactionParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [AccountActivityRetrieveTransactionParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountActivityRetrieveTransactionParams]. */ + class Builder internal constructor() { + + private var transactionToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + accountActivityRetrieveTransactionParams: AccountActivityRetrieveTransactionParams + ) = apply { + transactionToken = accountActivityRetrieveTransactionParams.transactionToken + additionalHeaders = + accountActivityRetrieveTransactionParams.additionalHeaders.toBuilder() + additionalQueryParams = + accountActivityRetrieveTransactionParams.additionalQueryParams.toBuilder() + } + + fun transactionToken(transactionToken: String?) = apply { + this.transactionToken = transactionToken + } + + /** Alias for calling [Builder.transactionToken] with `transactionToken.orElse(null)`. */ + fun transactionToken(transactionToken: Optional) = + transactionToken(transactionToken.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 [AccountActivityRetrieveTransactionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams( + transactionToken, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> transactionToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityRetrieveTransactionParams && transactionToken == other.transactionToken && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(transactionToken, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AccountActivityRetrieveTransactionParams{transactionToken=$transactionToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt new file mode 100644 index 000000000..3aaa5a6f3 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt @@ -0,0 +1,8923 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +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.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Response containing multiple transaction types */ +@JsonDeserialize(using = AccountActivityRetrieveTransactionResponse.Deserializer::class) +@JsonSerialize(using = AccountActivityRetrieveTransactionResponse.Serializer::class) +class AccountActivityRetrieveTransactionResponse +private constructor( + private val financialTransaction: FinancialTransaction? = null, + private val bookTransferTransaction: BookTransferTransaction? = null, + private val cardTransaction: CardTransaction? = null, + private val paymentTransaction: PaymentTransaction? = null, + private val externalPayment: ExternalPayment? = null, + private val managementOperationTransaction: ManagementOperationTransaction? = null, + private val _json: JsonValue? = null, +) { + + /** Financial transaction with inheritance from unified base transaction */ + fun financialTransaction(): Optional = + Optional.ofNullable(financialTransaction) + + /** Book transfer transaction */ + fun bookTransferTransaction(): Optional = + Optional.ofNullable(bookTransferTransaction) + + /** Base class for all transaction types in the ledger service */ + fun cardTransaction(): Optional = Optional.ofNullable(cardTransaction) + + /** Payment transaction */ + fun paymentTransaction(): Optional = Optional.ofNullable(paymentTransaction) + + fun externalPayment(): Optional = Optional.ofNullable(externalPayment) + + fun managementOperationTransaction(): Optional = + Optional.ofNullable(managementOperationTransaction) + + fun isFinancialTransaction(): Boolean = financialTransaction != null + + fun isBookTransferTransaction(): Boolean = bookTransferTransaction != null + + fun isCardTransaction(): Boolean = cardTransaction != null + + fun isPaymentTransaction(): Boolean = paymentTransaction != null + + fun isExternalPayment(): Boolean = externalPayment != null + + fun isManagementOperationTransaction(): Boolean = managementOperationTransaction != null + + /** Financial transaction with inheritance from unified base transaction */ + fun asFinancialTransaction(): FinancialTransaction = + financialTransaction.getOrThrow("financialTransaction") + + /** Book transfer transaction */ + fun asBookTransferTransaction(): BookTransferTransaction = + bookTransferTransaction.getOrThrow("bookTransferTransaction") + + /** Base class for all transaction types in the ledger service */ + fun asCardTransaction(): CardTransaction = cardTransaction.getOrThrow("cardTransaction") + + /** Payment transaction */ + fun asPaymentTransaction(): PaymentTransaction = + paymentTransaction.getOrThrow("paymentTransaction") + + fun asExternalPayment(): ExternalPayment = externalPayment.getOrThrow("externalPayment") + + fun asManagementOperationTransaction(): ManagementOperationTransaction = + managementOperationTransaction.getOrThrow("managementOperationTransaction") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + financialTransaction != null -> visitor.visitFinancialTransaction(financialTransaction) + bookTransferTransaction != null -> + visitor.visitBookTransferTransaction(bookTransferTransaction) + cardTransaction != null -> visitor.visitCardTransaction(cardTransaction) + paymentTransaction != null -> visitor.visitPaymentTransaction(paymentTransaction) + externalPayment != null -> visitor.visitExternalPayment(externalPayment) + managementOperationTransaction != null -> + visitor.visitManagementOperationTransaction(managementOperationTransaction) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AccountActivityRetrieveTransactionResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFinancialTransaction(financialTransaction: FinancialTransaction) { + financialTransaction.validate() + } + + override fun visitBookTransferTransaction( + bookTransferTransaction: BookTransferTransaction + ) { + bookTransferTransaction.validate() + } + + override fun visitCardTransaction(cardTransaction: CardTransaction) { + cardTransaction.validate() + } + + override fun visitPaymentTransaction(paymentTransaction: PaymentTransaction) { + paymentTransaction.validate() + } + + override fun visitExternalPayment(externalPayment: ExternalPayment) { + externalPayment.validate() + } + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ) { + managementOperationTransaction.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitFinancialTransaction(financialTransaction: FinancialTransaction) = + financialTransaction.validity() + + override fun visitBookTransferTransaction( + bookTransferTransaction: BookTransferTransaction + ) = bookTransferTransaction.validity() + + override fun visitCardTransaction(cardTransaction: CardTransaction) = + cardTransaction.validity() + + override fun visitPaymentTransaction(paymentTransaction: PaymentTransaction) = + paymentTransaction.validity() + + override fun visitExternalPayment(externalPayment: ExternalPayment) = + externalPayment.validity() + + override fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ) = managementOperationTransaction.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountActivityRetrieveTransactionResponse && financialTransaction == other.financialTransaction && bookTransferTransaction == other.bookTransferTransaction && cardTransaction == other.cardTransaction && paymentTransaction == other.paymentTransaction && externalPayment == other.externalPayment && managementOperationTransaction == other.managementOperationTransaction /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(financialTransaction, bookTransferTransaction, cardTransaction, paymentTransaction, externalPayment, managementOperationTransaction) /* spotless:on */ + + override fun toString(): String = + when { + financialTransaction != null -> + "AccountActivityRetrieveTransactionResponse{financialTransaction=$financialTransaction}" + bookTransferTransaction != null -> + "AccountActivityRetrieveTransactionResponse{bookTransferTransaction=$bookTransferTransaction}" + cardTransaction != null -> + "AccountActivityRetrieveTransactionResponse{cardTransaction=$cardTransaction}" + paymentTransaction != null -> + "AccountActivityRetrieveTransactionResponse{paymentTransaction=$paymentTransaction}" + externalPayment != null -> + "AccountActivityRetrieveTransactionResponse{externalPayment=$externalPayment}" + managementOperationTransaction != null -> + "AccountActivityRetrieveTransactionResponse{managementOperationTransaction=$managementOperationTransaction}" + _json != null -> "AccountActivityRetrieveTransactionResponse{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid AccountActivityRetrieveTransactionResponse") + } + + companion object { + + /** Financial transaction with inheritance from unified base transaction */ + @JvmStatic + fun ofFinancialTransaction(financialTransaction: FinancialTransaction) = + AccountActivityRetrieveTransactionResponse(financialTransaction = financialTransaction) + + /** Book transfer transaction */ + @JvmStatic + fun ofBookTransferTransaction(bookTransferTransaction: BookTransferTransaction) = + AccountActivityRetrieveTransactionResponse( + bookTransferTransaction = bookTransferTransaction + ) + + /** Base class for all transaction types in the ledger service */ + @JvmStatic + fun ofCardTransaction(cardTransaction: CardTransaction) = + AccountActivityRetrieveTransactionResponse(cardTransaction = cardTransaction) + + /** Payment transaction */ + @JvmStatic + fun ofPaymentTransaction(paymentTransaction: PaymentTransaction) = + AccountActivityRetrieveTransactionResponse(paymentTransaction = paymentTransaction) + + @JvmStatic + fun ofExternalPayment(externalPayment: ExternalPayment) = + AccountActivityRetrieveTransactionResponse(externalPayment = externalPayment) + + @JvmStatic + fun ofManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ) = + AccountActivityRetrieveTransactionResponse( + managementOperationTransaction = managementOperationTransaction + ) + } + + /** + * An interface that defines how to map each variant of + * [AccountActivityRetrieveTransactionResponse] to a value of type [T]. + */ + interface Visitor { + + /** Financial transaction with inheritance from unified base transaction */ + fun visitFinancialTransaction(financialTransaction: FinancialTransaction): T + + /** Book transfer transaction */ + fun visitBookTransferTransaction(bookTransferTransaction: BookTransferTransaction): T + + /** Base class for all transaction types in the ledger service */ + fun visitCardTransaction(cardTransaction: CardTransaction): T + + /** Payment transaction */ + fun visitPaymentTransaction(paymentTransaction: PaymentTransaction): T + + fun visitExternalPayment(externalPayment: ExternalPayment): T + + fun visitManagementOperationTransaction( + managementOperationTransaction: ManagementOperationTransaction + ): T + + /** + * Maps an unknown variant of [AccountActivityRetrieveTransactionResponse] to a value of + * type [T]. + * + * An instance of [AccountActivityRetrieveTransactionResponse] can contain an unknown + * variant if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException( + "Unknown AccountActivityRetrieveTransactionResponse: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + AccountActivityRetrieveTransactionResponse::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): AccountActivityRetrieveTransactionResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityRetrieveTransactionResponse( + financialTransaction = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityRetrieveTransactionResponse( + bookTransferTransaction = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityRetrieveTransactionResponse( + cardTransaction = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityRetrieveTransactionResponse( + paymentTransaction = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountActivityRetrieveTransactionResponse( + externalPayment = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + AccountActivityRetrieveTransactionResponse( + managementOperationTransaction = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> AccountActivityRetrieveTransactionResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + AccountActivityRetrieveTransactionResponse::class + ) { + + override fun serialize( + value: AccountActivityRetrieveTransactionResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.financialTransaction != null -> + generator.writeObject(value.financialTransaction) + value.bookTransferTransaction != null -> + generator.writeObject(value.bookTransferTransaction) + value.cardTransaction != null -> generator.writeObject(value.cardTransaction) + value.paymentTransaction != null -> generator.writeObject(value.paymentTransaction) + value.externalPayment != null -> generator.writeObject(value.externalPayment) + value.managementOperationTransaction != null -> + generator.writeObject(value.managementOperationTransaction) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid AccountActivityRetrieveTransactionResponse" + ) + } + } + } + + /** Financial transaction with inheritance from unified base transaction */ + class FinancialTransaction + private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + descriptor, + events, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + status, + updated, + mutableMapOf(), + ) + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * Transaction category + * + * @throws LithicInvalidDataException 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(): TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * Currency of the transaction, represented in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Transaction descriptor + * + * @throws LithicInvalidDataException 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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * List of transaction events + * + * @throws LithicInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Financial account token associated with the transaction + * + * @throws LithicInvalidDataException 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 financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Pending amount in cents + * + * @throws LithicInvalidDataException 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 pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * Transaction result + * + * @throws LithicInvalidDataException 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 result(): TransactionResult = result.getRequired("result") + + /** + * Settled amount in cents + * + * @throws LithicInvalidDataException 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 settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException 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(): TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * 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 [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @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 [FinancialTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .family() + * .financialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FinancialTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var financialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(financialTransaction: FinancialTransaction) = apply { + token = financialTransaction.token + category = financialTransaction.category + created = financialTransaction.created + currency = financialTransaction.currency + descriptor = financialTransaction.descriptor + events = financialTransaction.events.map { it.toMutableList() } + family = financialTransaction.family + financialAccountToken = financialTransaction.financialAccountToken + pendingAmount = financialTransaction.pendingAmount + result = financialTransaction.result + settledAmount = financialTransaction.settledAmount + status = financialTransaction.status + updated = financialTransaction.updated + additionalProperties = financialTransaction.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Transaction category */ + fun category(category: TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [TransactionCategory] + * 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 + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Currency of the transaction, represented in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Transaction descriptor */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** List of transaction events */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Financial account token associated with the transaction */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Pending amount in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** Transaction result */ + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Settled amount in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] 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 } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + 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 [FinancialTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .family() + * .financialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FinancialTransaction = + FinancialTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("descriptor", descriptor), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("updated", updated), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FinancialTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + descriptor() + events() + family().validate() + financialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + /** Transaction category */ + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transaction result */ + class TransactionResult + @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] 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 { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionResult && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FinancialTransaction && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && events == other.events && family == other.family && financialAccountToken == other.financialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && updated == other.updated && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, events, family, financialAccountToken, pendingAmount, result, settledAmount, status, updated, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FinancialTransaction{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, events=$events, family=$family, financialAccountToken=$financialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, updated=$updated, additionalProperties=$additionalProperties}" + } + + /** Book transfer transaction */ + class BookTransferTransaction + private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val fromFinancialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val toFinancialAccountToken: JsonField, + private val updated: JsonField, + private val externalId: JsonField, + private val externalResource: JsonField, + private val transactionSeries: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fromFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("to_financial_account_token") + @ExcludeMissing + toFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, + result, + settledAmount, + status, + toFinancialAccountToken, + updated, + externalId, + externalResource, + transactionSeries, + mutableMapOf(), + ) + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException 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(): TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * Currency of the transaction in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * List of events associated with this book transfer + * + * @throws LithicInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Source account token + * + * @throws LithicInvalidDataException 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 fromFinancialAccountToken(): String = + fromFinancialAccountToken.getRequired("from_financial_account_token") + + /** + * The pending amount of the transaction in cents + * + * @throws LithicInvalidDataException 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 pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException 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 result(): TransactionResult = result.getRequired("result") + + /** + * The settled amount of the transaction in cents + * + * @throws LithicInvalidDataException 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 settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException 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(): TransactionStatus = status.getRequired("status") + + /** + * Destination account token + * + * @throws LithicInvalidDataException 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 toFinancialAccountToken(): String = + toFinancialAccountToken.getRequired("to_financial_account_token") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * External identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [fromFinancialAccountToken]. + * + * Unlike [fromFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fun _fromFinancialAccountToken(): JsonField = fromFinancialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * 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 [toFinancialAccountToken]. + * + * Unlike [toFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("to_financial_account_token") + @ExcludeMissing + fun _toFinancialAccountToken(): JsonField = toFinancialAccountToken + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + + @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 [BookTransferTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BookTransferTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var fromFinancialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var toFinancialAccountToken: JsonField? = null + private var updated: JsonField? = null + private var externalId: JsonField = JsonMissing.of() + private var externalResource: JsonField = JsonMissing.of() + private var transactionSeries: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bookTransferTransaction: BookTransferTransaction) = apply { + token = bookTransferTransaction.token + category = bookTransferTransaction.category + created = bookTransferTransaction.created + currency = bookTransferTransaction.currency + events = bookTransferTransaction.events.map { it.toMutableList() } + family = bookTransferTransaction.family + fromFinancialAccountToken = bookTransferTransaction.fromFinancialAccountToken + pendingAmount = bookTransferTransaction.pendingAmount + result = bookTransferTransaction.result + settledAmount = bookTransferTransaction.settledAmount + status = bookTransferTransaction.status + toFinancialAccountToken = bookTransferTransaction.toFinancialAccountToken + updated = bookTransferTransaction.updated + externalId = bookTransferTransaction.externalId + externalResource = bookTransferTransaction.externalResource + transactionSeries = bookTransferTransaction.transactionSeries + additionalProperties = bookTransferTransaction.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [TransactionCategory] + * 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 + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** List of events associated with this book transfer */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Source account token */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) + + /** + * Sets [Builder.fromFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.fromFinancialAccountToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: JsonField) = apply { + this.fromFinancialAccountToken = fromFinancialAccountToken + } + + /** The pending amount of the transaction in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** The settled amount of the transaction in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] 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 } + + /** Destination account token */ + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + + /** + * Sets [Builder.toFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.toFinancialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + this.toFinancialAccountToken = toFinancialAccountToken + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** External identifier for the transaction */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** + * Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. + */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed + * [ExternalResource] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + + fun transactionSeries(transactionSeries: TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** + * Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. + */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [TransactionSeries] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transactionSeries(transactionSeries: JsonField) = apply { + this.transactionSeries = transactionSeries + } + + 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 [BookTransferTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BookTransferTransaction = + BookTransferTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("toFinancialAccountToken", toFinancialAccountToken), + checkRequired("updated", updated), + externalId, + externalResource, + transactionSeries, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BookTransferTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + events() + family().validate() + fromFinancialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + toFinancialAccountToken() + updated() + externalId() + externalResource().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (fromFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (toFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionResult + @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] 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 { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionResult && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionSeries + private constructor( + private val relatedTransactionEventToken: JsonField, + private val relatedTransactionToken: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + relatedTransactionEventToken: JsonField = JsonMissing.of(), + @JsonProperty("related_transaction_token") + @ExcludeMissing + relatedTransactionToken: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(relatedTransactionEventToken, relatedTransactionToken, type, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun relatedTransactionEventToken(): Optional = + relatedTransactionEventToken.getOptional("related_transaction_event_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun relatedTransactionToken(): Optional = + relatedTransactionToken.getOptional("related_transaction_token") + + /** + * @throws LithicInvalidDataException 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(): String = type.getRequired("type") + + /** + * Returns the raw JSON value of [relatedTransactionEventToken]. + * + * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken + + /** + * Returns the raw JSON value of [relatedTransactionToken]. + * + * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("related_transaction_token") + @ExcludeMissing + fun _relatedTransactionToken(): JsonField = relatedTransactionToken + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TransactionSeries]. */ + class Builder internal constructor() { + + private var relatedTransactionEventToken: JsonField? = null + private var relatedTransactionToken: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transactionSeries: TransactionSeries) = apply { + relatedTransactionEventToken = transactionSeries.relatedTransactionEventToken + relatedTransactionToken = transactionSeries.relatedTransactionToken + type = transactionSeries.type + additionalProperties = transactionSeries.additionalProperties.toMutableMap() + } + + fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = + relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) + + /** + * Alias for calling [Builder.relatedTransactionEventToken] with + * `relatedTransactionEventToken.orElse(null)`. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: Optional) = + relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) + + /** + * Sets [Builder.relatedTransactionEventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedTransactionEventToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = + apply { + this.relatedTransactionEventToken = relatedTransactionEventToken + } + + fun relatedTransactionToken(relatedTransactionToken: String?) = + relatedTransactionToken(JsonField.ofNullable(relatedTransactionToken)) + + /** + * Alias for calling [Builder.relatedTransactionToken] with + * `relatedTransactionToken.orElse(null)`. + */ + fun relatedTransactionToken(relatedTransactionToken: Optional) = + relatedTransactionToken(relatedTransactionToken.getOrNull()) + + /** + * Sets [Builder.relatedTransactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedTransactionToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun relatedTransactionToken(relatedTransactionToken: JsonField) = apply { + this.relatedTransactionToken = relatedTransactionToken + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [TransactionSeries]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TransactionSeries = + TransactionSeries( + checkRequired("relatedTransactionEventToken", relatedTransactionEventToken), + checkRequired("relatedTransactionToken", relatedTransactionToken), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TransactionSeries = apply { + if (validated) { + return@apply + } + + relatedTransactionEventToken() + relatedTransactionToken() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (relatedTransactionEventToken.asKnown().isPresent) 1 else 0) + + (if (relatedTransactionToken.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionSeries && relatedTransactionEventToken == other.relatedTransactionEventToken && relatedTransactionToken == other.relatedTransactionToken && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(relatedTransactionEventToken, relatedTransactionToken, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BookTransferTransaction && token == other.token && category == other.category && created == other.created && currency == other.currency && events == other.events && family == other.family && fromFinancialAccountToken == other.fromFinancialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && toFinancialAccountToken == other.toFinancialAccountToken && updated == other.updated && externalId == other.externalId && externalResource == other.externalResource && transactionSeries == other.transactionSeries && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, events, family, fromFinancialAccountToken, pendingAmount, result, settledAmount, status, toFinancialAccountToken, updated, externalId, externalResource, transactionSeries, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BookTransferTransaction{token=$token, category=$category, created=$created, currency=$currency, events=$events, family=$family, fromFinancialAccountToken=$fromFinancialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, toFinancialAccountToken=$toFinancialAccountToken, updated=$updated, externalId=$externalId, externalResource=$externalResource, transactionSeries=$transactionSeries, additionalProperties=$additionalProperties}" + } + + /** Base class for all transaction types in the ledger service */ + class CardTransaction + private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val acquirerFee: JsonField, + private val acquirerReferenceNumber: JsonField, + private val amount: JsonField, + private val amounts: JsonField, + private val authorizationAmount: JsonField, + private val authorizationCode: JsonField, + private val avs: JsonField, + private val cardToken: JsonField, + private val cardholderAuthentication: JsonField, + private val created: JsonField, + private val merchant: JsonField, + private val merchantAmount: JsonField, + private val merchantAuthorizationAmount: JsonField, + private val merchantCurrency: JsonField, + private val network: JsonField, + private val networkRiskScore: JsonField, + private val pos: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val tokenInfo: JsonField, + private val updated: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_fee") + @ExcludeMissing + acquirerFee: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_reference_number") + @ExcludeMissing + acquirerReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("amounts") + @ExcludeMissing + amounts: JsonField = JsonMissing.of(), + @JsonProperty("authorization_amount") + @ExcludeMissing + authorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("authorization_code") + @ExcludeMissing + authorizationCode: JsonField = JsonMissing.of(), + @JsonProperty("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), + @JsonProperty("card_token") + @ExcludeMissing + cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_authentication") + @ExcludeMissing + cardholderAuthentication: JsonField = + JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("merchant") + @ExcludeMissing + merchant: JsonField = JsonMissing.of(), + @JsonProperty("merchant_amount") + @ExcludeMissing + merchantAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_authorization_amount") + @ExcludeMissing + merchantAuthorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_currency") + @ExcludeMissing + merchantCurrency: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("network_risk_score") + @ExcludeMissing + networkRiskScore: JsonField = JsonMissing.of(), + @JsonProperty("pos") @ExcludeMissing pos: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("token_info") + @ExcludeMissing + tokenInfo: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + acquirerFee, + acquirerReferenceNumber, + amount, + amounts, + authorizationAmount, + authorizationCode, + avs, + cardToken, + cardholderAuthentication, + created, + merchant, + merchantAmount, + merchantAuthorizationAmount, + merchantCurrency, + network, + networkRiskScore, + pos, + result, + settledAmount, + status, + tokenInfo, + updated, + events, + family, + mutableMapOf(), + ) + + fun toTransaction(): Transaction = + Transaction.builder() + .token(token) + .accountToken(accountToken) + .acquirerFee(acquirerFee) + .acquirerReferenceNumber(acquirerReferenceNumber) + .amount(amount) + .amounts(amounts) + .authorizationAmount(authorizationAmount) + .authorizationCode(authorizationCode) + .avs(avs) + .cardToken(cardToken) + .cardholderAuthentication(cardholderAuthentication) + .created(created) + .merchant(merchant) + .merchantAmount(merchantAmount) + .merchantAuthorizationAmount(merchantAuthorizationAmount) + .merchantCurrency(merchantCurrency) + .network(network) + .networkRiskScore(networkRiskScore) + .pos(pos) + .result(result) + .settledAmount(settledAmount) + .status(status) + .tokenInfo(tokenInfo) + .updated(updated) + .events(events) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * The token for the account associated with this transaction. + * + * @throws LithicInvalidDataException 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the + * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative + * value to indicate credited fees. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun acquirerFee(): Optional = acquirerFee.getOptional("acquirer_fee") + + /** + * Unique identifier assigned to a transaction by the acquirer that can be used in dispute + * and chargeback filing. This field has been deprecated in favor of the + * `acquirer_reference_number` that resides in the event-level `network_info`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(): Optional = + acquirerReferenceNumber.getOptional("acquirer_reference_number") + + /** + * When the transaction is pending, this represents the authorization amount of the + * transaction in the anticipated settlement currency. Once the transaction has settled, + * this field represents the settled amount in the settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") fun amount(): Long = amount.getRequired("amount") + + /** + * @throws LithicInvalidDataException 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 amounts(): Transaction.TransactionAmounts = amounts.getRequired("amounts") + + /** + * The authorization amount of the transaction in the anticipated settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun authorizationAmount(): Optional = + authorizationAmount.getOptional("authorization_amount") + + /** + * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with + * networks. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authorizationCode(): Optional = + authorizationCode.getOptional("authorization_code") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun avs(): Optional = avs.getOptional("avs") + + /** + * Token for the card used in this transaction. + * + * @throws LithicInvalidDataException 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 cardToken(): String = cardToken.getRequired("card_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderAuthentication(): Optional = + cardholderAuthentication.getOptional("cardholder_authentication") + + /** + * Date and time when the transaction first occurred. UTC time zone. + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * @throws LithicInvalidDataException 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 merchant(): Transaction.Merchant = merchant.getRequired("merchant") + + /** + * Analogous to the 'amount', but in the merchant currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantAmount(): Optional = merchantAmount.getOptional("merchant_amount") + + /** + * Analogous to the 'authorization_amount', but in the merchant currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(): Optional = + merchantAuthorizationAmount.getOptional("merchant_authorization_amount") + + /** + * 3-character alphabetic ISO 4217 code for the local currency of the transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantCurrency(): String = merchantCurrency.getRequired("merchant_currency") + + /** + * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine the + * network code from the upstream provider. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun network(): Optional = network.getOptional("network") + + /** + * Network-provided score assessing risk level associated with a given authorization. Scores + * are on a range of 0-999, with 0 representing the lowest risk and 999 representing the + * highest risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkRiskScore(): Optional = networkRiskScore.getOptional("network_risk_score") + + /** + * @throws LithicInvalidDataException 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 pos(): Transaction.Pos = pos.getRequired("pos") + + /** + * @throws LithicInvalidDataException 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 result(): Transaction.DeclineResult = result.getRequired("result") + + /** + * The settled amount of the transaction in the settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Status of the transaction. + * + * @throws LithicInvalidDataException 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(): Transaction.Status = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenInfo(): Optional = tokenInfo.getOptional("token_info") + + /** + * Date and time when the transaction last updated. UTC time zone. + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = events.getOptional("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [acquirerFee]. + * + * Unlike [acquirerFee], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("acquirer_fee") + @ExcludeMissing + fun _acquirerFee(): JsonField = acquirerFee + + /** + * Returns the raw JSON value of [acquirerReferenceNumber]. + * + * Unlike [acquirerReferenceNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("acquirer_reference_number") + @ExcludeMissing + fun _acquirerReferenceNumber(): JsonField = acquirerReferenceNumber + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [amounts]. + * + * Unlike [amounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amounts") + @ExcludeMissing + fun _amounts(): JsonField = amounts + + /** + * Returns the raw JSON value of [authorizationAmount]. + * + * Unlike [authorizationAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("authorization_amount") + @ExcludeMissing + fun _authorizationAmount(): JsonField = authorizationAmount + + /** + * Returns the raw JSON value of [authorizationCode]. + * + * Unlike [authorizationCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorization_code") + @ExcludeMissing + fun _authorizationCode(): JsonField = authorizationCode + + /** + * Returns the raw JSON value of [avs]. + * + * Unlike [avs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("avs") @ExcludeMissing fun _avs(): JsonField = avs + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [cardholderAuthentication]. + * + * Unlike [cardholderAuthentication], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_authentication") + @ExcludeMissing + fun _cardholderAuthentication(): JsonField = + cardholderAuthentication + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [merchant]. + * + * Unlike [merchant], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant") + @ExcludeMissing + fun _merchant(): JsonField = merchant + + /** + * Returns the raw JSON value of [merchantAmount]. + * + * Unlike [merchantAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_amount") + @ExcludeMissing + fun _merchantAmount(): JsonField = merchantAmount + + /** + * Returns the raw JSON value of [merchantAuthorizationAmount]. + * + * Unlike [merchantAuthorizationAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_authorization_amount") + @ExcludeMissing + fun _merchantAuthorizationAmount(): JsonField = merchantAuthorizationAmount + + /** + * Returns the raw JSON value of [merchantCurrency]. + * + * Unlike [merchantCurrency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_currency") + @ExcludeMissing + fun _merchantCurrency(): JsonField = merchantCurrency + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network") + @ExcludeMissing + fun _network(): JsonField = network + + /** + * Returns the raw JSON value of [networkRiskScore]. + * + * Unlike [networkRiskScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_risk_score") + @ExcludeMissing + fun _networkRiskScore(): JsonField = networkRiskScore + + /** + * Returns the raw JSON value of [pos]. + * + * Unlike [pos], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pos") @ExcludeMissing fun _pos(): JsonField = pos + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * 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 [tokenInfo]. + * + * Unlike [tokenInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token_info") + @ExcludeMissing + fun _tokenInfo(): JsonField = tokenInfo + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + @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 [CardTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .acquirerFee() + * .acquirerReferenceNumber() + * .amount() + * .amounts() + * .authorizationAmount() + * .authorizationCode() + * .avs() + * .cardToken() + * .cardholderAuthentication() + * .created() + * .merchant() + * .merchantAmount() + * .merchantAuthorizationAmount() + * .merchantCurrency() + * .network() + * .networkRiskScore() + * .pos() + * .result() + * .settledAmount() + * .status() + * .tokenInfo() + * .updated() + * .family() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var acquirerFee: JsonField? = null + private var acquirerReferenceNumber: JsonField? = null + private var amount: JsonField? = null + private var amounts: JsonField? = null + private var authorizationAmount: JsonField? = null + private var authorizationCode: JsonField? = null + private var avs: JsonField? = null + private var cardToken: JsonField? = null + private var cardholderAuthentication: JsonField? = + null + private var created: JsonField? = null + private var merchant: JsonField? = null + private var merchantAmount: JsonField? = null + private var merchantAuthorizationAmount: JsonField? = null + private var merchantCurrency: JsonField? = null + private var network: JsonField? = null + private var networkRiskScore: JsonField? = null + private var pos: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var tokenInfo: JsonField? = null + private var updated: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardTransaction: CardTransaction) = apply { + token = cardTransaction.token + accountToken = cardTransaction.accountToken + acquirerFee = cardTransaction.acquirerFee + acquirerReferenceNumber = cardTransaction.acquirerReferenceNumber + amount = cardTransaction.amount + amounts = cardTransaction.amounts + authorizationAmount = cardTransaction.authorizationAmount + authorizationCode = cardTransaction.authorizationCode + avs = cardTransaction.avs + cardToken = cardTransaction.cardToken + cardholderAuthentication = cardTransaction.cardholderAuthentication + created = cardTransaction.created + merchant = cardTransaction.merchant + merchantAmount = cardTransaction.merchantAmount + merchantAuthorizationAmount = cardTransaction.merchantAuthorizationAmount + merchantCurrency = cardTransaction.merchantCurrency + network = cardTransaction.network + networkRiskScore = cardTransaction.networkRiskScore + pos = cardTransaction.pos + result = cardTransaction.result + settledAmount = cardTransaction.settledAmount + status = cardTransaction.status + tokenInfo = cardTransaction.tokenInfo + updated = cardTransaction.updated + events = cardTransaction.events.map { it.toMutableList() } + family = cardTransaction.family + additionalProperties = cardTransaction.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The token for the account associated with this transaction. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of + * the currency. Will be zero if no fee is assessed. Rebates may be transmitted as a + * negative value to indicate credited fees. + */ + fun acquirerFee(acquirerFee: Long?) = acquirerFee(JsonField.ofNullable(acquirerFee)) + + /** + * Alias for [Builder.acquirerFee]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun acquirerFee(acquirerFee: Long) = acquirerFee(acquirerFee as Long?) + + /** Alias for calling [Builder.acquirerFee] with `acquirerFee.orElse(null)`. */ + fun acquirerFee(acquirerFee: Optional) = acquirerFee(acquirerFee.getOrNull()) + + /** + * Sets [Builder.acquirerFee] to an arbitrary JSON value. + * + * You should usually call [Builder.acquirerFee] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acquirerFee(acquirerFee: JsonField) = apply { this.acquirerFee = acquirerFee } + + /** + * Unique identifier assigned to a transaction by the acquirer that can be used in + * dispute and chargeback filing. This field has been deprecated in favor of the + * `acquirer_reference_number` that resides in the event-level `network_info`. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: String?) = + acquirerReferenceNumber(JsonField.ofNullable(acquirerReferenceNumber)) + + /** + * Alias for calling [Builder.acquirerReferenceNumber] with + * `acquirerReferenceNumber.orElse(null)`. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: Optional) = + acquirerReferenceNumber(acquirerReferenceNumber.getOrNull()) + + /** + * Sets [Builder.acquirerReferenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.acquirerReferenceNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: JsonField) = apply { + this.acquirerReferenceNumber = acquirerReferenceNumber + } + + /** + * When the transaction is pending, this represents the authorization amount of the + * transaction in the anticipated settlement currency. Once the transaction has settled, + * this field represents the settled amount in the settlement currency. + */ + @Deprecated("deprecated") 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. + */ + @Deprecated("deprecated") + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun amounts(amounts: Transaction.TransactionAmounts) = amounts(JsonField.of(amounts)) + + /** + * Sets [Builder.amounts] to an arbitrary JSON value. + * + * You should usually call [Builder.amounts] with a well-typed + * [Transaction.TransactionAmounts] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun amounts(amounts: JsonField) = apply { + this.amounts = amounts + } + + /** + * The authorization amount of the transaction in the anticipated settlement currency. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long?) = + authorizationAmount(JsonField.ofNullable(authorizationAmount)) + + /** + * Alias for [Builder.authorizationAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long) = + authorizationAmount(authorizationAmount as Long?) + + /** + * Alias for calling [Builder.authorizationAmount] with + * `authorizationAmount.orElse(null)`. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Optional) = + authorizationAmount(authorizationAmount.getOrNull()) + + /** + * Sets [Builder.authorizationAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: JsonField) = apply { + this.authorizationAmount = authorizationAmount + } + + /** + * A fixed-width 6-digit numeric identifier that can be used to identify a transaction + * with networks. + */ + fun authorizationCode(authorizationCode: String?) = + authorizationCode(JsonField.ofNullable(authorizationCode)) + + /** + * Alias for calling [Builder.authorizationCode] with `authorizationCode.orElse(null)`. + */ + fun authorizationCode(authorizationCode: Optional) = + authorizationCode(authorizationCode.getOrNull()) + + /** + * Sets [Builder.authorizationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorizationCode(authorizationCode: JsonField) = apply { + this.authorizationCode = authorizationCode + } + + fun avs(avs: Transaction.Avs?) = avs(JsonField.ofNullable(avs)) + + /** Alias for calling [Builder.avs] with `avs.orElse(null)`. */ + fun avs(avs: Optional) = avs(avs.getOrNull()) + + /** + * Sets [Builder.avs] to an arbitrary JSON value. + * + * You should usually call [Builder.avs] with a well-typed [Transaction.Avs] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun avs(avs: JsonField) = apply { this.avs = avs } + + /** Token for the card used in this transaction. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + fun cardholderAuthentication( + cardholderAuthentication: Transaction.CardholderAuthentication? + ) = cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + + /** + * Alias for calling [Builder.cardholderAuthentication] with + * `cardholderAuthentication.orElse(null)`. + */ + fun cardholderAuthentication( + cardholderAuthentication: Optional + ) = cardholderAuthentication(cardholderAuthentication.getOrNull()) + + /** + * Sets [Builder.cardholderAuthentication] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderAuthentication] with a well-typed + * [Transaction.CardholderAuthentication] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun cardholderAuthentication( + cardholderAuthentication: JsonField + ) = apply { this.cardholderAuthentication = cardholderAuthentication } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun merchant(merchant: Transaction.Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Transaction.Merchant] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun merchant(merchant: JsonField) = apply { + this.merchant = merchant + } + + /** Analogous to the 'amount', but in the merchant currency. */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long?) = + merchantAmount(JsonField.ofNullable(merchantAmount)) + + /** + * Alias for [Builder.merchantAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + + /** Alias for calling [Builder.merchantAmount] with `merchantAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Optional) = + merchantAmount(merchantAmount.getOrNull()) + + /** + * Sets [Builder.merchantAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: JsonField) = apply { + this.merchantAmount = merchantAmount + } + + /** Analogous to the 'authorization_amount', but in the merchant currency. */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long?) = + merchantAuthorizationAmount(JsonField.ofNullable(merchantAuthorizationAmount)) + + /** + * Alias for [Builder.merchantAuthorizationAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long) = + merchantAuthorizationAmount(merchantAuthorizationAmount as Long?) + + /** + * Alias for calling [Builder.merchantAuthorizationAmount] with + * `merchantAuthorizationAmount.orElse(null)`. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Optional) = + merchantAuthorizationAmount(merchantAuthorizationAmount.getOrNull()) + + /** + * Sets [Builder.merchantAuthorizationAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAuthorizationAmount] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: JsonField) = apply { + this.merchantAuthorizationAmount = merchantAuthorizationAmount + } + + /** 3-character alphabetic ISO 4217 code for the local currency of the transaction. */ + @Deprecated("deprecated") + fun merchantCurrency(merchantCurrency: String) = + merchantCurrency(JsonField.of(merchantCurrency)) + + /** + * Sets [Builder.merchantCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCurrency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun merchantCurrency(merchantCurrency: JsonField) = apply { + this.merchantCurrency = merchantCurrency + } + + /** + * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine + * the network code from the upstream provider. + */ + fun network(network: Transaction.Network?) = network(JsonField.ofNullable(network)) + + /** Alias for calling [Builder.network] with `network.orElse(null)`. */ + fun network(network: Optional) = network(network.getOrNull()) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [Transaction.Network] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun network(network: JsonField) = apply { this.network = network } + + /** + * Network-provided score assessing risk level associated with a given authorization. + * Scores are on a range of 0-999, with 0 representing the lowest risk and 999 + * representing the highest risk. For Visa transactions, where the raw score has a range + * of 0-99, Lithic will normalize the score by multiplying the raw score by 10x. + */ + fun networkRiskScore(networkRiskScore: Long?) = + networkRiskScore(JsonField.ofNullable(networkRiskScore)) + + /** + * Alias for [Builder.networkRiskScore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun networkRiskScore(networkRiskScore: Long) = + networkRiskScore(networkRiskScore as Long?) + + /** + * Alias for calling [Builder.networkRiskScore] with `networkRiskScore.orElse(null)`. + */ + fun networkRiskScore(networkRiskScore: Optional) = + networkRiskScore(networkRiskScore.getOrNull()) + + /** + * Sets [Builder.networkRiskScore] to an arbitrary JSON value. + * + * You should usually call [Builder.networkRiskScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkRiskScore(networkRiskScore: JsonField) = apply { + this.networkRiskScore = networkRiskScore + } + + fun pos(pos: Transaction.Pos) = pos(JsonField.of(pos)) + + /** + * Sets [Builder.pos] to an arbitrary JSON value. + * + * You should usually call [Builder.pos] with a well-typed [Transaction.Pos] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pos(pos: JsonField) = apply { this.pos = pos } + + fun result(result: Transaction.DeclineResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [Transaction.DeclineResult] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + /** The settled amount of the transaction in the settlement currency. */ + @Deprecated("deprecated") + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Status of the transaction. */ + fun status(status: Transaction.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Transaction.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 } + + fun tokenInfo(tokenInfo: Transaction.TokenInfo?) = + tokenInfo(JsonField.ofNullable(tokenInfo)) + + /** Alias for calling [Builder.tokenInfo] with `tokenInfo.orElse(null)`. */ + fun tokenInfo(tokenInfo: Optional) = + tokenInfo(tokenInfo.getOrNull()) + + /** + * Sets [Builder.tokenInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenInfo] with a well-typed [Transaction.TokenInfo] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tokenInfo(tokenInfo: JsonField) = apply { + this.tokenInfo = tokenInfo + } + + /** Date and time when the transaction last updated. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Transaction.TransactionEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Transaction.TransactionEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + 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 [CardTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .acquirerFee() + * .acquirerReferenceNumber() + * .amount() + * .amounts() + * .authorizationAmount() + * .authorizationCode() + * .avs() + * .cardToken() + * .cardholderAuthentication() + * .created() + * .merchant() + * .merchantAmount() + * .merchantAuthorizationAmount() + * .merchantCurrency() + * .network() + * .networkRiskScore() + * .pos() + * .result() + * .settledAmount() + * .status() + * .tokenInfo() + * .updated() + * .family() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTransaction = + CardTransaction( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("acquirerFee", acquirerFee), + checkRequired("acquirerReferenceNumber", acquirerReferenceNumber), + checkRequired("amount", amount), + checkRequired("amounts", amounts), + checkRequired("authorizationAmount", authorizationAmount), + checkRequired("authorizationCode", authorizationCode), + checkRequired("avs", avs), + checkRequired("cardToken", cardToken), + checkRequired("cardholderAuthentication", cardholderAuthentication), + checkRequired("created", created), + checkRequired("merchant", merchant), + checkRequired("merchantAmount", merchantAmount), + checkRequired("merchantAuthorizationAmount", merchantAuthorizationAmount), + checkRequired("merchantCurrency", merchantCurrency), + checkRequired("network", network), + checkRequired("networkRiskScore", networkRiskScore), + checkRequired("pos", pos), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("tokenInfo", tokenInfo), + checkRequired("updated", updated), + (events ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("family", family), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTransaction = apply { + if (validated) { + return@apply + } + + token() + accountToken() + acquirerFee() + acquirerReferenceNumber() + amount() + amounts().validate() + authorizationAmount() + authorizationCode() + avs().ifPresent { it.validate() } + cardToken() + cardholderAuthentication().ifPresent { it.validate() } + created() + merchant().validate() + merchantAmount() + merchantAuthorizationAmount() + merchantCurrency() + network().ifPresent { it.validate() } + networkRiskScore() + pos().validate() + result().validate() + settledAmount() + status().validate() + tokenInfo().ifPresent { it.validate() } + updated() + events().ifPresent { it.forEach { it.validate() } } + family().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (acquirerFee.asKnown().isPresent) 1 else 0) + + (if (acquirerReferenceNumber.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (amounts.asKnown().getOrNull()?.validity() ?: 0) + + (if (authorizationAmount.asKnown().isPresent) 1 else 0) + + (if (authorizationCode.asKnown().isPresent) 1 else 0) + + (avs.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (cardholderAuthentication.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (merchantAmount.asKnown().isPresent) 1 else 0) + + (if (merchantAuthorizationAmount.asKnown().isPresent) 1 else 0) + + (if (merchantCurrency.asKnown().isPresent) 1 else 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (networkRiskScore.asKnown().isPresent) 1 else 0) + + (pos.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (tokenInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CardTransaction && token == other.token && accountToken == other.accountToken && acquirerFee == other.acquirerFee && acquirerReferenceNumber == other.acquirerReferenceNumber && amount == other.amount && amounts == other.amounts && authorizationAmount == other.authorizationAmount && authorizationCode == other.authorizationCode && avs == other.avs && cardToken == other.cardToken && cardholderAuthentication == other.cardholderAuthentication && created == other.created && merchant == other.merchant && merchantAmount == other.merchantAmount && merchantAuthorizationAmount == other.merchantAuthorizationAmount && merchantCurrency == other.merchantCurrency && network == other.network && networkRiskScore == other.networkRiskScore && pos == other.pos && result == other.result && settledAmount == other.settledAmount && status == other.status && tokenInfo == other.tokenInfo && updated == other.updated && events == other.events && family == other.family && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, accountToken, acquirerFee, acquirerReferenceNumber, amount, amounts, authorizationAmount, authorizationCode, avs, cardToken, cardholderAuthentication, created, merchant, merchantAmount, merchantAuthorizationAmount, merchantCurrency, network, networkRiskScore, pos, result, settledAmount, status, tokenInfo, updated, events, family, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTransaction{token=$token, accountToken=$accountToken, acquirerFee=$acquirerFee, acquirerReferenceNumber=$acquirerReferenceNumber, amount=$amount, amounts=$amounts, authorizationAmount=$authorizationAmount, authorizationCode=$authorizationCode, avs=$avs, cardToken=$cardToken, cardholderAuthentication=$cardholderAuthentication, created=$created, merchant=$merchant, merchantAmount=$merchantAmount, merchantAuthorizationAmount=$merchantAuthorizationAmount, merchantCurrency=$merchantCurrency, network=$network, networkRiskScore=$networkRiskScore, pos=$pos, result=$result, settledAmount=$settledAmount, status=$status, tokenInfo=$tokenInfo, updated=$updated, events=$events, family=$family, additionalProperties=$additionalProperties}" + } + + /** Payment transaction */ + class PaymentTransaction + private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val descriptor: JsonField, + private val direction: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val method: JsonField, + private val methodAttributes: JsonField, + private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val source: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val currency: JsonField, + private val expectedReleaseDate: JsonField, + private val externalBankAccountToken: JsonField, + private val userDefinedId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), + @JsonProperty("method_attributes") + @ExcludeMissing + methodAttributes: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("expected_release_date") + @ExcludeMissing + expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_account_token") + @ExcludeMissing + externalBankAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + descriptor, + direction, + events, + family, + financialAccountToken, + method, + methodAttributes, + pendingAmount, + relatedAccountTokens, + result, + settledAmount, + source, + status, + updated, + currency, + expectedReleaseDate, + externalBankAccountToken, + userDefinedId, + mutableMapOf(), + ) + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException 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 token(): String = token.getRequired("token") + + /** + * Transaction category + * + * @throws LithicInvalidDataException 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(): TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException 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 created(): OffsetDateTime = created.getRequired("created") + + /** + * Transaction descriptor + * + * @throws LithicInvalidDataException 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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * Transfer direction + * + * @throws LithicInvalidDataException 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 direction(): Direction = direction.getRequired("direction") + + /** + * List of transaction events + * + * @throws LithicInvalidDataException 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 events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException 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 family(): TransactionFamilyTypes = family.getRequired("family") + + /** + * Financial account token + * + * @throws LithicInvalidDataException 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 financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Transfer method + * + * @throws LithicInvalidDataException 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 method(): Method = method.getRequired("method") + + /** + * Method-specific attributes + * + * @throws LithicInvalidDataException 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 methodAttributes(): MethodAttributes = methodAttributes.getRequired("method_attributes") + + /** + * Pending amount in cents + * + * @throws LithicInvalidDataException 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 pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * Related account tokens for the transaction + * + * @throws LithicInvalidDataException 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 relatedAccountTokens(): RelatedAccountTokens = + relatedAccountTokens.getRequired("related_account_tokens") + + /** + * Transaction result + * + * @throws LithicInvalidDataException 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 result(): TransactionResult = result.getRequired("result") + + /** + * Settled amount in cents + * + * @throws LithicInvalidDataException 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 settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Transaction source + * + * @throws LithicInvalidDataException 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 source(): Source = source.getRequired("source") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException 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(): TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException 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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Currency of the transaction in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * Expected release date for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expectedReleaseDate(): Optional = + expectedReleaseDate.getOptional("expected_release_date") + + /** + * External bank account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalBankAccountToken(): Optional = + externalBankAccountToken.getOptional("external_bank_account_token") + + /** + * User-defined identifier + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [methodAttributes]. + * + * Unlike [methodAttributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * 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 [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [expectedReleaseDate]. + * + * Unlike [expectedReleaseDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("expected_release_date") + @ExcludeMissing + fun _expectedReleaseDate(): JsonField = expectedReleaseDate + + /** + * Returns the raw JSON value of [externalBankAccountToken]. + * + * Unlike [externalBankAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken(): JsonField = externalBankAccountToken + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + @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 [PaymentTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var expectedReleaseDate: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentTransaction: PaymentTransaction) = apply { + token = paymentTransaction.token + category = paymentTransaction.category + created = paymentTransaction.created + descriptor = paymentTransaction.descriptor + direction = paymentTransaction.direction + events = paymentTransaction.events.map { it.toMutableList() } + family = paymentTransaction.family + financialAccountToken = paymentTransaction.financialAccountToken + method = paymentTransaction.method + methodAttributes = paymentTransaction.methodAttributes + pendingAmount = paymentTransaction.pendingAmount + relatedAccountTokens = paymentTransaction.relatedAccountTokens + result = paymentTransaction.result + settledAmount = paymentTransaction.settledAmount + source = paymentTransaction.source + status = paymentTransaction.status + updated = paymentTransaction.updated + currency = paymentTransaction.currency + expectedReleaseDate = paymentTransaction.expectedReleaseDate + externalBankAccountToken = paymentTransaction.externalBankAccountToken + userDefinedId = paymentTransaction.userDefinedId + additionalProperties = paymentTransaction.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Transaction category */ + fun category(category: TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [TransactionCategory] + * 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 + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Transaction descriptor */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Transfer direction */ + fun direction(direction: Direction) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [Direction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun direction(direction: JsonField) = apply { this.direction = direction } + + /** List of transaction events */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: JsonValue) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [TransactionFamilyTypes] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Financial account token */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Transfer method */ + fun method(method: Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** Method-specific attributes */ + fun methodAttributes(methodAttributes: MethodAttributes) = + methodAttributes(JsonField.of(methodAttributes)) + + /** + * Sets [Builder.methodAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.methodAttributes] with a well-typed + * [MethodAttributes] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun methodAttributes(methodAttributes: JsonField) = apply { + this.methodAttributes = methodAttributes + } + + /** Alias for calling [methodAttributes] with `MethodAttributes.ofAch(ach)`. */ + fun methodAttributes(ach: MethodAttributes.AchMethodAttributes) = + methodAttributes(MethodAttributes.ofAch(ach)) + + /** Alias for calling [methodAttributes] with `MethodAttributes.ofWire(wire)`. */ + fun methodAttributes(wire: MethodAttributes.WireMethodAttributes) = + methodAttributes(MethodAttributes.ofWire(wire)) + + /** Pending amount in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** Related account tokens for the transaction */ + fun relatedAccountTokens(relatedAccountTokens: RelatedAccountTokens) = + relatedAccountTokens(JsonField.of(relatedAccountTokens)) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [RelatedAccountTokens] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = + apply { + this.relatedAccountTokens = relatedAccountTokens + } + + /** Transaction result */ + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Settled amount in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Transaction source */ + fun source(source: Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] 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 } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Expected release date for the transaction */ + fun expectedReleaseDate(expectedReleaseDate: LocalDate?) = + expectedReleaseDate(JsonField.ofNullable(expectedReleaseDate)) + + /** + * Alias for calling [Builder.expectedReleaseDate] with + * `expectedReleaseDate.orElse(null)`. + */ + fun expectedReleaseDate(expectedReleaseDate: Optional) = + expectedReleaseDate(expectedReleaseDate.getOrNull()) + + /** + * Sets [Builder.expectedReleaseDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedReleaseDate] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun expectedReleaseDate(expectedReleaseDate: JsonField) = apply { + this.expectedReleaseDate = expectedReleaseDate + } + + /** External bank account token */ + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) + + /** + * Alias for calling [Builder.externalBankAccountToken] with + * `externalBankAccountToken.orElse(null)`. + */ + fun externalBankAccountToken(externalBankAccountToken: Optional) = + externalBankAccountToken(externalBankAccountToken.getOrNull()) + + /** + * Sets [Builder.externalBankAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + /** User-defined identifier */ + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + 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 [PaymentTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentTransaction = + PaymentTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("descriptor", descriptor), + checkRequired("direction", direction), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("method", method), + checkRequired("methodAttributes", methodAttributes), + checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("source", source), + checkRequired("status", status), + checkRequired("updated", updated), + currency, + expectedReleaseDate, + externalBankAccountToken, + userDefinedId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + descriptor() + direction().validate() + events() + family().validate() + financialAccountToken() + method().validate() + methodAttributes().validate() + pendingAmount() + relatedAccountTokens().validate() + result().validate() + settledAmount() + source().validate() + status().validate() + updated() + currency() + expectedReleaseDate() + externalBankAccountToken() + userDefinedId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.size ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (if (externalBankAccountToken.asKnown().isPresent) 1 else 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + /** Transaction category */ + class TransactionCategory + @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 ACH = of("ACH") + + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + + @JvmField val CARD = of("CARD") + + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } + + /** An enum containing [TransactionCategory]'s known values. */ + enum class Known { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + } + + /** + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionCategory] 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 { + ACH, + BALANCE_OR_FUNDING, + CARD, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + EXTERNAL_WIRE, + MANAGEMENT_ADJUSTMENT, + MANAGEMENT_DISPUTE, + MANAGEMENT_FEE, + MANAGEMENT_REWARD, + MANAGEMENT_DISBURSEMENT, + PROGRAM_FUNDING, + /** + * An enum member indicating that [TransactionCategory] 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) { + ACH -> Value.ACH + BALANCE_OR_FUNDING -> Value.BALANCE_OR_FUNDING + CARD -> Value.CARD + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Value.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Value.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Value.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Value.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Value.PROGRAM_FUNDING + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH -> Known.ACH + BALANCE_OR_FUNDING -> Known.BALANCE_OR_FUNDING + CARD -> Known.CARD + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT + MANAGEMENT_DISPUTE -> Known.MANAGEMENT_DISPUTE + MANAGEMENT_FEE -> Known.MANAGEMENT_FEE + MANAGEMENT_REWARD -> Known.MANAGEMENT_REWARD + MANAGEMENT_DISBURSEMENT -> Known.MANAGEMENT_DISBURSEMENT + PROGRAM_FUNDING -> Known.PROGRAM_FUNDING + else -> throw LithicInvalidDataException("Unknown TransactionCategory: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionCategory && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transfer direction */ + class Direction @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 CREDIT = of("CREDIT") + + @JvmField val DEBIT = of("DEBIT") + + @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) + } + + /** An enum containing [Direction]'s known values. */ + enum class Known { + CREDIT, + DEBIT, + } + + /** + * An enum containing [Direction]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Direction] 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 { + CREDIT, + DEBIT, + /** + * An enum member indicating that [Direction] 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) { + CREDIT -> Value.CREDIT + DEBIT -> Value.DEBIT + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREDIT -> Known.CREDIT + DEBIT -> Known.DEBIT + else -> throw LithicInvalidDataException("Unknown Direction: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Direction = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Direction && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CARD = of("CARD") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + + @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + + @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + } + + /** An enum containing [TransactionFamilyTypes]'s known values. */ + enum class Known { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + } + + /** + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionFamilyTypes] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CARD -> Value.CARD + PAYMENT -> Value.PAYMENT + TRANSFER -> Value.TRANSFER + INTERNAL -> Value.INTERNAL + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Value.MANAGEMENT_OPERATION + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD -> Known.CARD + PAYMENT -> Known.PAYMENT + TRANSFER -> Known.TRANSFER + INTERNAL -> Known.INTERNAL + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + MANAGEMENT_OPERATION -> Known.MANAGEMENT_OPERATION + else -> + throw LithicInvalidDataException("Unknown TransactionFamilyTypes: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionFamilyTypes && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transfer method */ + class Method @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 ACH_NEXT_DAY = of("ACH_NEXT_DAY") + + @JvmField val ACH_SAME_DAY = of("ACH_SAME_DAY") + + @JvmField val WIRE = of("WIRE") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + ACH_NEXT_DAY, + ACH_SAME_DAY, + WIRE, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] 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 { + ACH_NEXT_DAY, + ACH_SAME_DAY, + WIRE, + /** + * An enum member indicating that [Method] 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) { + ACH_NEXT_DAY -> Value.ACH_NEXT_DAY + ACH_SAME_DAY -> Value.ACH_SAME_DAY + WIRE -> Value.WIRE + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACH_NEXT_DAY -> Known.ACH_NEXT_DAY + ACH_SAME_DAY -> Known.ACH_SAME_DAY + WIRE -> Known.WIRE + else -> throw LithicInvalidDataException("Unknown Method: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Method && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Method-specific attributes */ + @JsonDeserialize(using = MethodAttributes.Deserializer::class) + @JsonSerialize(using = MethodAttributes.Serializer::class) + class MethodAttributes + private constructor( + private val ach: AchMethodAttributes? = null, + private val wire: WireMethodAttributes? = null, + private val _json: JsonValue? = null, + ) { + + fun ach(): Optional = Optional.ofNullable(ach) + + fun wire(): Optional = Optional.ofNullable(wire) + + fun isAch(): Boolean = ach != null + + fun isWire(): Boolean = wire != null + + fun asAch(): AchMethodAttributes = ach.getOrThrow("ach") + + fun asWire(): WireMethodAttributes = wire.getOrThrow("wire") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + ach != null -> visitor.visitAch(ach) + wire != null -> visitor.visitWire(wire) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MethodAttributes = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAch(ach: AchMethodAttributes) { + ach.validate() + } + + override fun visitWire(wire: WireMethodAttributes) { + wire.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitAch(ach: AchMethodAttributes) = ach.validity() + + override fun visitWire(wire: WireMethodAttributes) = wire.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MethodAttributes && ach == other.ach && wire == other.wire /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(ach, wire) /* spotless:on */ + + override fun toString(): String = + when { + ach != null -> "MethodAttributes{ach=$ach}" + wire != null -> "MethodAttributes{wire=$wire}" + _json != null -> "MethodAttributes{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MethodAttributes") + } + + companion object { + + @JvmStatic fun ofAch(ach: AchMethodAttributes) = MethodAttributes(ach = ach) + + @JvmStatic fun ofWire(wire: WireMethodAttributes) = MethodAttributes(wire = wire) + } + + /** + * An interface that defines how to map each variant of [MethodAttributes] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAch(ach: AchMethodAttributes): T + + fun visitWire(wire: WireMethodAttributes): T + + /** + * Maps an unknown variant of [MethodAttributes] to a value of type [T]. + * + * An instance of [MethodAttributes] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown MethodAttributes: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MethodAttributes::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MethodAttributes { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MethodAttributes(ach = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MethodAttributes(wire = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> MethodAttributes(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MethodAttributes::class) { + + override fun serialize( + value: MethodAttributes, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.ach != null -> generator.writeObject(value.ach) + value.wire != null -> generator.writeObject(value.wire) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MethodAttributes") + } + } + } + + class AchMethodAttributes + private constructor( + private val secCode: JsonField, + private val addenda: JsonField, + private val companyId: JsonField, + private val receiptRoutingNumber: JsonField, + private val retries: JsonField, + private val returnReasonCode: JsonField, + private val traceNumbers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sec_code") + @ExcludeMissing + secCode: JsonField = JsonMissing.of(), + @JsonProperty("addenda") + @ExcludeMissing + addenda: JsonField = JsonMissing.of(), + @JsonProperty("company_id") + @ExcludeMissing + companyId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_routing_number") + @ExcludeMissing + receiptRoutingNumber: JsonField = JsonMissing.of(), + @JsonProperty("retries") + @ExcludeMissing + retries: JsonField = JsonMissing.of(), + @JsonProperty("return_reason_code") + @ExcludeMissing + returnReasonCode: JsonField = JsonMissing.of(), + @JsonProperty("trace_numbers") + @ExcludeMissing + traceNumbers: JsonField> = JsonMissing.of(), + ) : this( + secCode, + addenda, + companyId, + receiptRoutingNumber, + retries, + returnReasonCode, + traceNumbers, + mutableMapOf(), + ) + + /** + * SEC code for ACH transaction + * + * @throws LithicInvalidDataException 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 secCode(): SecCode = secCode.getRequired("sec_code") + + /** + * Addenda information + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addenda(): Optional = addenda.getOptional("addenda") + + /** + * Company ID for the ACH transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun companyId(): Optional = companyId.getOptional("company_id") + + /** + * Receipt routing number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun receiptRoutingNumber(): Optional = + receiptRoutingNumber.getOptional("receipt_routing_number") + + /** + * Number of retries attempted + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun retries(): Optional = retries.getOptional("retries") + + /** + * Return reason code if the transaction was returned + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnReasonCode(): Optional = + returnReasonCode.getOptional("return_reason_code") + + /** + * Trace numbers for the ACH transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun traceNumbers(): Optional> = + traceNumbers.getOptional("trace_numbers") + + /** + * Returns the raw JSON value of [secCode]. + * + * Unlike [secCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sec_code") + @ExcludeMissing + fun _secCode(): JsonField = secCode + + /** + * Returns the raw JSON value of [addenda]. + * + * Unlike [addenda], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("addenda") @ExcludeMissing fun _addenda(): JsonField = addenda + + /** + * Returns the raw JSON value of [companyId]. + * + * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId + + /** + * Returns the raw JSON value of [receiptRoutingNumber]. + * + * Unlike [receiptRoutingNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("receipt_routing_number") + @ExcludeMissing + fun _receiptRoutingNumber(): JsonField = receiptRoutingNumber + + /** + * Returns the raw JSON value of [retries]. + * + * Unlike [retries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("retries") @ExcludeMissing fun _retries(): JsonField = retries + + /** + * Returns the raw JSON value of [returnReasonCode]. + * + * Unlike [returnReasonCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_reason_code") + @ExcludeMissing + fun _returnReasonCode(): JsonField = returnReasonCode + + /** + * Returns the raw JSON value of [traceNumbers]. + * + * Unlike [traceNumbers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("trace_numbers") + @ExcludeMissing + fun _traceNumbers(): JsonField> = traceNumbers + + @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 + * [AchMethodAttributes]. + * + * The following fields are required: + * ```java + * .secCode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AchMethodAttributes]. */ + class Builder internal constructor() { + + private var secCode: JsonField? = null + private var addenda: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var receiptRoutingNumber: JsonField = JsonMissing.of() + private var retries: JsonField = JsonMissing.of() + private var returnReasonCode: JsonField = JsonMissing.of() + private var traceNumbers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(achMethodAttributes: AchMethodAttributes) = apply { + secCode = achMethodAttributes.secCode + addenda = achMethodAttributes.addenda + companyId = achMethodAttributes.companyId + receiptRoutingNumber = achMethodAttributes.receiptRoutingNumber + retries = achMethodAttributes.retries + returnReasonCode = achMethodAttributes.returnReasonCode + traceNumbers = achMethodAttributes.traceNumbers.map { it.toMutableList() } + additionalProperties = + achMethodAttributes.additionalProperties.toMutableMap() + } + + /** SEC code for ACH transaction */ + fun secCode(secCode: SecCode) = secCode(JsonField.of(secCode)) + + /** + * Sets [Builder.secCode] to an arbitrary JSON value. + * + * You should usually call [Builder.secCode] with a well-typed [SecCode] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun secCode(secCode: JsonField) = apply { this.secCode = secCode } + + /** Addenda information */ + fun addenda(addenda: String?) = addenda(JsonField.ofNullable(addenda)) + + /** Alias for calling [Builder.addenda] with `addenda.orElse(null)`. */ + fun addenda(addenda: Optional) = addenda(addenda.getOrNull()) + + /** + * Sets [Builder.addenda] to an arbitrary JSON value. + * + * You should usually call [Builder.addenda] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addenda(addenda: JsonField) = apply { this.addenda = addenda } + + /** Company ID for the ACH transaction */ + fun companyId(companyId: String?) = companyId(JsonField.ofNullable(companyId)) + + /** Alias for calling [Builder.companyId] with `companyId.orElse(null)`. */ + fun companyId(companyId: Optional) = companyId(companyId.getOrNull()) + + /** + * Sets [Builder.companyId] to an arbitrary JSON value. + * + * You should usually call [Builder.companyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun companyId(companyId: JsonField) = apply { + this.companyId = companyId + } + + /** Receipt routing number */ + fun receiptRoutingNumber(receiptRoutingNumber: String?) = + receiptRoutingNumber(JsonField.ofNullable(receiptRoutingNumber)) + + /** + * Alias for calling [Builder.receiptRoutingNumber] with + * `receiptRoutingNumber.orElse(null)`. + */ + fun receiptRoutingNumber(receiptRoutingNumber: Optional) = + receiptRoutingNumber(receiptRoutingNumber.getOrNull()) + + /** + * Sets [Builder.receiptRoutingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptRoutingNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receiptRoutingNumber(receiptRoutingNumber: JsonField) = apply { + this.receiptRoutingNumber = receiptRoutingNumber + } + + /** Number of retries attempted */ + fun retries(retries: Long?) = retries(JsonField.ofNullable(retries)) + + /** + * Alias for [Builder.retries]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun retries(retries: Long) = retries(retries as Long?) + + /** Alias for calling [Builder.retries] with `retries.orElse(null)`. */ + fun retries(retries: Optional) = retries(retries.getOrNull()) + + /** + * Sets [Builder.retries] to an arbitrary JSON value. + * + * You should usually call [Builder.retries] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun retries(retries: JsonField) = apply { this.retries = retries } + + /** Return reason code if the transaction was returned */ + fun returnReasonCode(returnReasonCode: String?) = + returnReasonCode(JsonField.ofNullable(returnReasonCode)) + + /** + * Alias for calling [Builder.returnReasonCode] with + * `returnReasonCode.orElse(null)`. + */ + fun returnReasonCode(returnReasonCode: Optional) = + returnReasonCode(returnReasonCode.getOrNull()) + + /** + * Sets [Builder.returnReasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.returnReasonCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnReasonCode(returnReasonCode: JsonField) = apply { + this.returnReasonCode = returnReasonCode + } + + /** Trace numbers for the ACH transaction */ + fun traceNumbers(traceNumbers: List) = + traceNumbers(JsonField.of(traceNumbers)) + + /** + * Sets [Builder.traceNumbers] to an arbitrary JSON value. + * + * You should usually call [Builder.traceNumbers] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun traceNumbers(traceNumbers: JsonField>) = apply { + this.traceNumbers = traceNumbers.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [traceNumbers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTraceNumber(traceNumber: String) = apply { + traceNumbers = + (traceNumbers ?: JsonField.of(mutableListOf())).also { + checkKnown("traceNumbers", it).add(traceNumber) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AchMethodAttributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .secCode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AchMethodAttributes = + AchMethodAttributes( + checkRequired("secCode", secCode), + addenda, + companyId, + receiptRoutingNumber, + retries, + returnReasonCode, + (traceNumbers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AchMethodAttributes = apply { + if (validated) { + return@apply + } + + secCode().validate() + addenda() + companyId() + receiptRoutingNumber() + retries() + returnReasonCode() + traceNumbers() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + (secCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (addenda.asKnown().isPresent) 1 else 0) + + (if (companyId.asKnown().isPresent) 1 else 0) + + (if (receiptRoutingNumber.asKnown().isPresent) 1 else 0) + + (if (retries.asKnown().isPresent) 1 else 0) + + (if (returnReasonCode.asKnown().isPresent) 1 else 0) + + (traceNumbers.asKnown().getOrNull()?.size ?: 0) + + /** SEC code for ACH transaction */ + class SecCode + @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 CCD = of("CCD") + + @JvmField val PPD = of("PPD") + + @JvmField val WEB = of("WEB") + + @JvmField val TEL = of("TEL") + + @JvmField val CIE = of("CIE") + + @JvmField val CTX = of("CTX") + + @JvmStatic fun of(value: String) = SecCode(JsonField.of(value)) + } + + /** An enum containing [SecCode]'s known values. */ + enum class Known { + CCD, + PPD, + WEB, + TEL, + CIE, + CTX, + } + + /** + * An enum containing [SecCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SecCode] 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 { + CCD, + PPD, + WEB, + TEL, + CIE, + CTX, + /** + * An enum member indicating that [SecCode] 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) { + CCD -> Value.CCD + PPD -> Value.PPD + WEB -> Value.WEB + TEL -> Value.TEL + CIE -> Value.CIE + CTX -> Value.CTX + 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 LithicInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CCD -> Known.CCD + PPD -> Known.PPD + WEB -> Known.WEB + TEL -> Known.TEL + CIE -> Known.CIE + CTX -> Known.CTX + else -> throw LithicInvalidDataException("Unknown SecCode: $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 LithicInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SecCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SecCode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AchMethodAttributes && secCode == other.secCode && addenda == other.addenda && companyId == other.companyId && receiptRoutingNumber == other.receiptRoutingNumber && retries == other.retries && returnReasonCode == other.returnReasonCode && traceNumbers == other.traceNumbers && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(secCode, addenda, companyId, receiptRoutingNumber, retries, returnReasonCode, traceNumbers, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AchMethodAttributes{secCode=$secCode, addenda=$addenda, companyId=$companyId, receiptRoutingNumber=$receiptRoutingNumber, retries=$retries, returnReasonCode=$returnReasonCode, traceNumbers=$traceNumbers, additionalProperties=$additionalProperties}" + } + + class WireMethodAttributes + private constructor( + private val wireTransferType: JsonField, + private val externalBankName: JsonField, + private val externalBankRoutingNumber: JsonField, + private val externalIndividualName: JsonField, + private val lithicBankName: JsonField, + private val lithicBankRoutingNumber: JsonField, + private val lithicIndividualName: JsonField, + private val previousTransfer: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("wire_transfer_type") + @ExcludeMissing + wireTransferType: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_name") + @ExcludeMissing + externalBankName: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_routing_number") + @ExcludeMissing + externalBankRoutingNumber: JsonField = JsonMissing.of(), + @JsonProperty("external_individual_name") + @ExcludeMissing + externalIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("lithic_bank_name") + @ExcludeMissing + lithicBankName: JsonField = JsonMissing.of(), + @JsonProperty("lithic_bank_routing_number") + @ExcludeMissing + lithicBankRoutingNumber: JsonField = JsonMissing.of(), + @JsonProperty("lithic_individual_name") + @ExcludeMissing + lithicIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("previous_transfer") + @ExcludeMissing + previousTransfer: JsonField = JsonMissing.of(), + ) : this( + wireTransferType, + externalBankName, + externalBankRoutingNumber, + externalIndividualName, + lithicBankName, + lithicBankRoutingNumber, + lithicIndividualName, + previousTransfer, + mutableMapOf(), + ) + + /** + * Type of wire transfer + * + * @throws LithicInvalidDataException 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 wireTransferType(): WireTransferType = + wireTransferType.getRequired("wire_transfer_type") + + /** + * External bank name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externalBankName(): Optional = + externalBankName.getOptional("external_bank_name") + + /** + * External bank routing number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externalBankRoutingNumber(): Optional = + externalBankRoutingNumber.getOptional("external_bank_routing_number") + + /** + * External individual name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun externalIndividualName(): Optional = + externalIndividualName.getOptional("external_individual_name") + + /** + * Lithic bank name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lithicBankName(): Optional = + lithicBankName.getOptional("lithic_bank_name") + + /** + * Lithic bank routing number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lithicBankRoutingNumber(): Optional = + lithicBankRoutingNumber.getOptional("lithic_bank_routing_number") + + /** + * Lithic individual name + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lithicIndividualName(): Optional = + lithicIndividualName.getOptional("lithic_individual_name") + + /** + * UUID of previous transfer if this is a retry + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun previousTransfer(): Optional = + previousTransfer.getOptional("previous_transfer") + + /** + * Returns the raw JSON value of [wireTransferType]. + * + * Unlike [wireTransferType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wire_transfer_type") + @ExcludeMissing + fun _wireTransferType(): JsonField = wireTransferType + + /** + * Returns the raw JSON value of [externalBankName]. + * + * Unlike [externalBankName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_bank_name") + @ExcludeMissing + fun _externalBankName(): JsonField = externalBankName + + /** + * Returns the raw JSON value of [externalBankRoutingNumber]. + * + * Unlike [externalBankRoutingNumber], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("external_bank_routing_number") + @ExcludeMissing + fun _externalBankRoutingNumber(): JsonField = externalBankRoutingNumber + + /** + * Returns the raw JSON value of [externalIndividualName]. + * + * Unlike [externalIndividualName], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("external_individual_name") + @ExcludeMissing + fun _externalIndividualName(): JsonField = externalIndividualName + + /** + * Returns the raw JSON value of [lithicBankName]. + * + * Unlike [lithicBankName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lithic_bank_name") + @ExcludeMissing + fun _lithicBankName(): JsonField = lithicBankName + + /** + * Returns the raw JSON value of [lithicBankRoutingNumber]. + * + * Unlike [lithicBankRoutingNumber], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lithic_bank_routing_number") + @ExcludeMissing + fun _lithicBankRoutingNumber(): JsonField = lithicBankRoutingNumber + + /** + * Returns the raw JSON value of [lithicIndividualName]. + * + * Unlike [lithicIndividualName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("lithic_individual_name") + @ExcludeMissing + fun _lithicIndividualName(): JsonField = lithicIndividualName + + /** + * Returns the raw JSON value of [previousTransfer]. + * + * Unlike [previousTransfer], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previous_transfer") + @ExcludeMissing + fun _previousTransfer(): JsonField = previousTransfer + + @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 + * [WireMethodAttributes]. + * + * The following fields are required: + * ```java + * .wireTransferType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WireMethodAttributes]. */ + class Builder internal constructor() { + + private var wireTransferType: JsonField? = null + private var externalBankName: JsonField = JsonMissing.of() + private var externalBankRoutingNumber: JsonField = JsonMissing.of() + private var externalIndividualName: JsonField = JsonMissing.of() + private var lithicBankName: JsonField = JsonMissing.of() + private var lithicBankRoutingNumber: JsonField = JsonMissing.of() + private var lithicIndividualName: JsonField = JsonMissing.of() + private var previousTransfer: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(wireMethodAttributes: WireMethodAttributes) = apply { + wireTransferType = wireMethodAttributes.wireTransferType + externalBankName = wireMethodAttributes.externalBankName + externalBankRoutingNumber = wireMethodAttributes.externalBankRoutingNumber + externalIndividualName = wireMethodAttributes.externalIndividualName + lithicBankName = wireMethodAttributes.lithicBankName + lithicBankRoutingNumber = wireMethodAttributes.lithicBankRoutingNumber + lithicIndividualName = wireMethodAttributes.lithicIndividualName + previousTransfer = wireMethodAttributes.previousTransfer + additionalProperties = + wireMethodAttributes.additionalProperties.toMutableMap() + } + + /** Type of wire transfer */ + fun wireTransferType(wireTransferType: WireTransferType) = + wireTransferType(JsonField.of(wireTransferType)) + + /** + * Sets [Builder.wireTransferType] to an arbitrary JSON value. + * + * You should usually call [Builder.wireTransferType] with a well-typed + * [WireTransferType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun wireTransferType(wireTransferType: JsonField) = apply { + this.wireTransferType = wireTransferType + } + + /** External bank name */ + fun externalBankName(externalBankName: String?) = + externalBankName(JsonField.ofNullable(externalBankName)) + + /** + * Alias for calling [Builder.externalBankName] with + * `externalBankName.orElse(null)`. + */ + fun externalBankName(externalBankName: Optional) = + externalBankName(externalBankName.getOrNull()) + + /** + * Sets [Builder.externalBankName] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalBankName(externalBankName: JsonField) = apply { + this.externalBankName = externalBankName + } + + /** External bank routing number */ + fun externalBankRoutingNumber(externalBankRoutingNumber: String?) = + externalBankRoutingNumber(JsonField.ofNullable(externalBankRoutingNumber)) + + /** + * Alias for calling [Builder.externalBankRoutingNumber] with + * `externalBankRoutingNumber.orElse(null)`. + */ + fun externalBankRoutingNumber(externalBankRoutingNumber: Optional) = + externalBankRoutingNumber(externalBankRoutingNumber.getOrNull()) + + /** + * Sets [Builder.externalBankRoutingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankRoutingNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalBankRoutingNumber(externalBankRoutingNumber: JsonField) = + apply { + this.externalBankRoutingNumber = externalBankRoutingNumber + } + + /** External individual name */ + fun externalIndividualName(externalIndividualName: String?) = + externalIndividualName(JsonField.ofNullable(externalIndividualName)) + + /** + * Alias for calling [Builder.externalIndividualName] with + * `externalIndividualName.orElse(null)`. + */ + fun externalIndividualName(externalIndividualName: Optional) = + externalIndividualName(externalIndividualName.getOrNull()) + + /** + * Sets [Builder.externalIndividualName] to an arbitrary JSON value. + * + * You should usually call [Builder.externalIndividualName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalIndividualName(externalIndividualName: JsonField) = apply { + this.externalIndividualName = externalIndividualName + } + + /** Lithic bank name */ + fun lithicBankName(lithicBankName: String?) = + lithicBankName(JsonField.ofNullable(lithicBankName)) + + /** + * Alias for calling [Builder.lithicBankName] with + * `lithicBankName.orElse(null)`. + */ + fun lithicBankName(lithicBankName: Optional) = + lithicBankName(lithicBankName.getOrNull()) + + /** + * Sets [Builder.lithicBankName] to an arbitrary JSON value. + * + * You should usually call [Builder.lithicBankName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lithicBankName(lithicBankName: JsonField) = apply { + this.lithicBankName = lithicBankName + } + + /** Lithic bank routing number */ + fun lithicBankRoutingNumber(lithicBankRoutingNumber: String?) = + lithicBankRoutingNumber(JsonField.ofNullable(lithicBankRoutingNumber)) + + /** + * Alias for calling [Builder.lithicBankRoutingNumber] with + * `lithicBankRoutingNumber.orElse(null)`. + */ + fun lithicBankRoutingNumber(lithicBankRoutingNumber: Optional) = + lithicBankRoutingNumber(lithicBankRoutingNumber.getOrNull()) + + /** + * Sets [Builder.lithicBankRoutingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.lithicBankRoutingNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lithicBankRoutingNumber(lithicBankRoutingNumber: JsonField) = + apply { + this.lithicBankRoutingNumber = lithicBankRoutingNumber + } + + /** Lithic individual name */ + fun lithicIndividualName(lithicIndividualName: String?) = + lithicIndividualName(JsonField.ofNullable(lithicIndividualName)) + + /** + * Alias for calling [Builder.lithicIndividualName] with + * `lithicIndividualName.orElse(null)`. + */ + fun lithicIndividualName(lithicIndividualName: Optional) = + lithicIndividualName(lithicIndividualName.getOrNull()) + + /** + * Sets [Builder.lithicIndividualName] to an arbitrary JSON value. + * + * You should usually call [Builder.lithicIndividualName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lithicIndividualName(lithicIndividualName: JsonField) = apply { + this.lithicIndividualName = lithicIndividualName + } + + /** UUID of previous transfer if this is a retry */ + fun previousTransfer(previousTransfer: String?) = + previousTransfer(JsonField.ofNullable(previousTransfer)) + + /** + * Alias for calling [Builder.previousTransfer] with + * `previousTransfer.orElse(null)`. + */ + fun previousTransfer(previousTransfer: Optional) = + previousTransfer(previousTransfer.getOrNull()) + + /** + * Sets [Builder.previousTransfer] to an arbitrary JSON value. + * + * You should usually call [Builder.previousTransfer] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousTransfer(previousTransfer: JsonField) = apply { + this.previousTransfer = previousTransfer + } + + 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 [WireMethodAttributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .wireTransferType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WireMethodAttributes = + WireMethodAttributes( + checkRequired("wireTransferType", wireTransferType), + externalBankName, + externalBankRoutingNumber, + externalIndividualName, + lithicBankName, + lithicBankRoutingNumber, + lithicIndividualName, + previousTransfer, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WireMethodAttributes = apply { + if (validated) { + return@apply + } + + wireTransferType().validate() + externalBankName() + externalBankRoutingNumber() + externalIndividualName() + lithicBankName() + lithicBankRoutingNumber() + lithicIndividualName() + previousTransfer() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 = + (wireTransferType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalBankName.asKnown().isPresent) 1 else 0) + + (if (externalBankRoutingNumber.asKnown().isPresent) 1 else 0) + + (if (externalIndividualName.asKnown().isPresent) 1 else 0) + + (if (lithicBankName.asKnown().isPresent) 1 else 0) + + (if (lithicBankRoutingNumber.asKnown().isPresent) 1 else 0) + + (if (lithicIndividualName.asKnown().isPresent) 1 else 0) + + (if (previousTransfer.asKnown().isPresent) 1 else 0) + + /** Type of wire transfer */ + class WireTransferType + @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 FEDWIRE = of("FEDWIRE") + + @JvmField val SWIFT = of("SWIFT") + + @JvmStatic fun of(value: String) = WireTransferType(JsonField.of(value)) + } + + /** An enum containing [WireTransferType]'s known values. */ + enum class Known { + FEDWIRE, + SWIFT, + } + + /** + * An enum containing [WireTransferType]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [WireTransferType] 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 { + FEDWIRE, + SWIFT, + /** + * An enum member indicating that [WireTransferType] 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) { + FEDWIRE -> Value.FEDWIRE + SWIFT -> Value.SWIFT + 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 LithicInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + FEDWIRE -> Known.FEDWIRE + SWIFT -> Known.SWIFT + else -> + throw LithicInvalidDataException("Unknown WireTransferType: $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 LithicInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): WireTransferType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is WireTransferType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is WireMethodAttributes && wireTransferType == other.wireTransferType && externalBankName == other.externalBankName && externalBankRoutingNumber == other.externalBankRoutingNumber && externalIndividualName == other.externalIndividualName && lithicBankName == other.lithicBankName && lithicBankRoutingNumber == other.lithicBankRoutingNumber && lithicIndividualName == other.lithicIndividualName && previousTransfer == other.previousTransfer && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(wireTransferType, externalBankName, externalBankRoutingNumber, externalIndividualName, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, previousTransfer, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WireMethodAttributes{wireTransferType=$wireTransferType, externalBankName=$externalBankName, externalBankRoutingNumber=$externalBankRoutingNumber, externalIndividualName=$externalIndividualName, lithicBankName=$lithicBankName, lithicBankRoutingNumber=$lithicBankRoutingNumber, lithicIndividualName=$lithicIndividualName, previousTransfer=$previousTransfer, additionalProperties=$additionalProperties}" + } + } + + /** Related account tokens for the transaction */ + class RelatedAccountTokens + private constructor( + private val accountToken: JsonField, + private val businessAccountToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("business_account_token") + @ExcludeMissing + businessAccountToken: JsonField = JsonMissing.of(), + ) : this(accountToken, businessAccountToken, mutableMapOf()) + + /** + * Globally unique identifier for the account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * Globally unique identifier for the business account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun businessAccountToken(): Optional = + businessAccountToken.getOptional("business_account_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [businessAccountToken]. + * + * Unlike [businessAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_account_token") + @ExcludeMissing + fun _businessAccountToken(): JsonField = businessAccountToken + + @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 [RelatedAccountTokens]. + * + * The following fields are required: + * ```java + * .accountToken() + * .businessAccountToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RelatedAccountTokens]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var businessAccountToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(relatedAccountTokens: RelatedAccountTokens) = apply { + accountToken = relatedAccountTokens.accountToken + businessAccountToken = relatedAccountTokens.businessAccountToken + additionalProperties = relatedAccountTokens.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the account */ + fun accountToken(accountToken: String?) = + accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = + accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Globally unique identifier for the business account */ + fun businessAccountToken(businessAccountToken: String?) = + businessAccountToken(JsonField.ofNullable(businessAccountToken)) + + /** + * Alias for calling [Builder.businessAccountToken] with + * `businessAccountToken.orElse(null)`. + */ + fun businessAccountToken(businessAccountToken: Optional) = + businessAccountToken(businessAccountToken.getOrNull()) + + /** + * Sets [Builder.businessAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.businessAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { + this.businessAccountToken = businessAccountToken + } + + 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 [RelatedAccountTokens]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .businessAccountToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RelatedAccountTokens = + RelatedAccountTokens( + checkRequired("accountToken", accountToken), + checkRequired("businessAccountToken", businessAccountToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RelatedAccountTokens = apply { + if (validated) { + return@apply + } + + accountToken() + businessAccountToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (accountToken.asKnown().isPresent) 1 else 0) + + (if (businessAccountToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RelatedAccountTokens && accountToken == other.accountToken && businessAccountToken == other.businessAccountToken && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accountToken, businessAccountToken, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RelatedAccountTokens{accountToken=$accountToken, businessAccountToken=$businessAccountToken, additionalProperties=$additionalProperties}" + } + + /** Transaction result */ + class TransactionResult + @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 APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] 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 { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] 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) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionResult && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Transaction source */ + class Source @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 LITHIC = of("LITHIC") + + @JvmField val EXTERNAL = of("EXTERNAL") + + @JvmField val CUSTOMER = of("CUSTOMER") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + LITHIC, + EXTERNAL, + CUSTOMER, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + LITHIC, + EXTERNAL, + CUSTOMER, + /** + * An enum member indicating that [Source] 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) { + LITHIC -> Value.LITHIC + EXTERNAL -> Value.EXTERNAL + CUSTOMER -> Value.CUSTOMER + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LITHIC -> Known.LITHIC + EXTERNAL -> Known.EXTERNAL + CUSTOMER -> Known.CUSTOMER + else -> throw LithicInvalidDataException("Unknown Source: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the transaction */ + class TransactionStatus + @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 PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionStatus] 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 { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] 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 -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + 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 LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $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 LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentTransaction && token == other.token && category == other.category && created == other.created && descriptor == other.descriptor && direction == other.direction && events == other.events && family == other.family && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && relatedAccountTokens == other.relatedAccountTokens && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && currency == other.currency && expectedReleaseDate == other.expectedReleaseDate && externalBankAccountToken == other.externalBankAccountToken && userDefinedId == other.userDefinedId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, category, created, descriptor, direction, events, family, financialAccountToken, method, methodAttributes, pendingAmount, relatedAccountTokens, result, settledAmount, source, status, updated, currency, expectedReleaseDate, externalBankAccountToken, userDefinedId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentTransaction{token=$token, category=$category, created=$created, descriptor=$descriptor, direction=$direction, events=$events, family=$family, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, currency=$currency, expectedReleaseDate=$expectedReleaseDate, externalBankAccountToken=$externalBankAccountToken, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt index bf966662a..7f2925103 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt @@ -18,6 +18,7 @@ import com.lithic.api.errors.LithicInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull class BookTransferResponse @@ -27,12 +28,14 @@ private constructor( private val created: JsonField, private val currency: JsonField, private val events: JsonField>, + private val externalResource: JsonField, private val fromFinancialAccountToken: JsonField, private val pendingAmount: JsonField, private val result: JsonField, private val settledAmount: JsonField, private val status: JsonField, private val toFinancialAccountToken: JsonValue, + private val transactionSeries: JsonField, private val updated: JsonField, private val additionalProperties: MutableMap, ) { @@ -48,6 +51,9 @@ private constructor( @JsonProperty("events") @ExcludeMissing events: JsonField> = JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), @JsonProperty("from_financial_account_token") @ExcludeMissing fromFinancialAccountToken: JsonField = JsonMissing.of(), @@ -62,6 +68,9 @@ private constructor( @JsonProperty("to_financial_account_token") @ExcludeMissing toFinancialAccountToken: JsonValue = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), @@ -71,12 +80,14 @@ private constructor( created, currency, events, + externalResource, fromFinancialAccountToken, pendingAmount, result, settledAmount, status, toFinancialAccountToken, + transactionSeries, updated, mutableMapOf(), ) @@ -122,6 +133,15 @@ private constructor( */ fun events(): List = events.getRequired("events") + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + /** * Globally unique identifier for the financial account or card that will send the funds. * Accepted type dependent on the program's use case. @@ -177,6 +197,15 @@ private constructor( @ExcludeMissing fun _toFinancialAccountToken(): JsonValue = toFinancialAccountToken + /** + * A series of transactions that are grouped together. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + /** * Date and time when the financial transaction was last updated. UTC time zone. * @@ -222,6 +251,16 @@ private constructor( @ExcludeMissing fun _events(): JsonField> = events + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + /** * Returns the raw JSON value of [fromFinancialAccountToken]. * @@ -264,6 +303,16 @@ private constructor( */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + /** * Returns the raw JSON value of [updated]. * @@ -295,12 +344,14 @@ private constructor( * .created() * .currency() * .events() + * .externalResource() * .fromFinancialAccountToken() * .pendingAmount() * .result() * .settledAmount() * .status() * .toFinancialAccountToken() + * .transactionSeries() * .updated() * ``` */ @@ -315,12 +366,14 @@ private constructor( private var created: JsonField? = null private var currency: JsonField? = null private var events: JsonField>? = null + private var externalResource: JsonField? = null private var fromFinancialAccountToken: JsonField? = null private var pendingAmount: JsonField? = null private var result: JsonField? = null private var settledAmount: JsonField? = null private var status: JsonField? = null private var toFinancialAccountToken: JsonValue? = null + private var transactionSeries: JsonField? = null private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -331,12 +384,14 @@ private constructor( created = bookTransferResponse.created currency = bookTransferResponse.currency events = bookTransferResponse.events.map { it.toMutableList() } + externalResource = bookTransferResponse.externalResource fromFinancialAccountToken = bookTransferResponse.fromFinancialAccountToken pendingAmount = bookTransferResponse.pendingAmount result = bookTransferResponse.result settledAmount = bookTransferResponse.settledAmount status = bookTransferResponse.status toFinancialAccountToken = bookTransferResponse.toFinancialAccountToken + transactionSeries = bookTransferResponse.transactionSeries updated = bookTransferResponse.updated additionalProperties = bookTransferResponse.additionalProperties.toMutableMap() } @@ -416,6 +471,25 @@ private constructor( } } + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed [ExternalResource] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + /** * Globally unique identifier for the financial account or card that will send the funds. * Accepted type dependent on the program's use case. @@ -505,6 +579,25 @@ private constructor( this.toFinancialAccountToken = toFinancialAccountToken } + /** A series of transactions that are grouped together. */ + fun transactionSeries(transactionSeries: TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed [TransactionSeries] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun transactionSeries(transactionSeries: JsonField) = apply { + this.transactionSeries = transactionSeries + } + /** Date and time when the financial transaction was last updated. UTC time zone. */ fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) @@ -548,12 +641,14 @@ private constructor( * .created() * .currency() * .events() + * .externalResource() * .fromFinancialAccountToken() * .pendingAmount() * .result() * .settledAmount() * .status() * .toFinancialAccountToken() + * .transactionSeries() * .updated() * ``` * @@ -566,12 +661,14 @@ private constructor( checkRequired("created", created), checkRequired("currency", currency), checkRequired("events", events).map { it.toImmutable() }, + checkRequired("externalResource", externalResource), checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), checkRequired("pendingAmount", pendingAmount), checkRequired("result", result), checkRequired("settledAmount", settledAmount), checkRequired("status", status), checkRequired("toFinancialAccountToken", toFinancialAccountToken), + checkRequired("transactionSeries", transactionSeries), checkRequired("updated", updated), additionalProperties.toMutableMap(), ) @@ -589,11 +686,13 @@ private constructor( created() currency() events().forEach { it.validate() } + externalResource().ifPresent { it.validate() } fromFinancialAccountToken() pendingAmount() result().validate() settledAmount() status().validate() + transactionSeries().ifPresent { it.validate() } updated() validated = true } @@ -618,11 +717,13 @@ private constructor( (if (created.asKnown().isPresent) 1 else 0) + (if (currency.asKnown().isPresent) 1 else 0) + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + (if (fromFinancialAccountToken.asKnown().isPresent) 1 else 0) + (if (pendingAmount.asKnown().isPresent) 1 else 0) + (result.asKnown().getOrNull()?.validity() ?: 0) + (if (settledAmount.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + (if (updated.asKnown().isPresent) 1 else 0) /** Category of the book transfer */ @@ -1763,20 +1864,277 @@ private constructor( override fun toString() = value.toString() } + /** A series of transactions that are grouped together. */ + class TransactionSeries + private constructor( + private val relatedTransactionEventToken: JsonField, + private val relatedTransactionToken: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + relatedTransactionEventToken: JsonField = JsonMissing.of(), + @JsonProperty("related_transaction_token") + @ExcludeMissing + relatedTransactionToken: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(relatedTransactionEventToken, relatedTransactionToken, type, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun relatedTransactionEventToken(): Optional = + relatedTransactionEventToken.getOptional("related_transaction_event_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun relatedTransactionToken(): Optional = + relatedTransactionToken.getOptional("related_transaction_token") + + /** + * @throws LithicInvalidDataException 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(): String = type.getRequired("type") + + /** + * Returns the raw JSON value of [relatedTransactionEventToken]. + * + * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken + + /** + * Returns the raw JSON value of [relatedTransactionToken]. + * + * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("related_transaction_token") + @ExcludeMissing + fun _relatedTransactionToken(): JsonField = relatedTransactionToken + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TransactionSeries]. */ + class Builder internal constructor() { + + private var relatedTransactionEventToken: JsonField? = null + private var relatedTransactionToken: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transactionSeries: TransactionSeries) = apply { + relatedTransactionEventToken = transactionSeries.relatedTransactionEventToken + relatedTransactionToken = transactionSeries.relatedTransactionToken + type = transactionSeries.type + additionalProperties = transactionSeries.additionalProperties.toMutableMap() + } + + fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = + relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) + + /** + * Alias for calling [Builder.relatedTransactionEventToken] with + * `relatedTransactionEventToken.orElse(null)`. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: Optional) = + relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) + + /** + * Sets [Builder.relatedTransactionEventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedTransactionEventToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = + apply { + this.relatedTransactionEventToken = relatedTransactionEventToken + } + + fun relatedTransactionToken(relatedTransactionToken: String?) = + relatedTransactionToken(JsonField.ofNullable(relatedTransactionToken)) + + /** + * Alias for calling [Builder.relatedTransactionToken] with + * `relatedTransactionToken.orElse(null)`. + */ + fun relatedTransactionToken(relatedTransactionToken: Optional) = + relatedTransactionToken(relatedTransactionToken.getOrNull()) + + /** + * Sets [Builder.relatedTransactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedTransactionToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun relatedTransactionToken(relatedTransactionToken: JsonField) = apply { + this.relatedTransactionToken = relatedTransactionToken + } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [TransactionSeries]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TransactionSeries = + TransactionSeries( + checkRequired("relatedTransactionEventToken", relatedTransactionEventToken), + checkRequired("relatedTransactionToken", relatedTransactionToken), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TransactionSeries = apply { + if (validated) { + return@apply + } + + relatedTransactionEventToken() + relatedTransactionToken() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (relatedTransactionEventToken.asKnown().isPresent) 1 else 0) + + (if (relatedTransactionToken.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TransactionSeries && relatedTransactionEventToken == other.relatedTransactionEventToken && relatedTransactionToken == other.relatedTransactionToken && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(relatedTransactionEventToken, relatedTransactionToken, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BookTransferResponse && token == other.token && category == other.category && created == other.created && currency == other.currency && events == other.events && fromFinancialAccountToken == other.fromFinancialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && toFinancialAccountToken == other.toFinancialAccountToken && updated == other.updated && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BookTransferResponse && token == other.token && category == other.category && created == other.created && currency == other.currency && events == other.events && externalResource == other.externalResource && fromFinancialAccountToken == other.fromFinancialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && toFinancialAccountToken == other.toFinancialAccountToken && transactionSeries == other.transactionSeries && updated == other.updated && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, events, fromFinancialAccountToken, pendingAmount, result, settledAmount, status, toFinancialAccountToken, updated, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, events, externalResource, fromFinancialAccountToken, pendingAmount, result, settledAmount, status, toFinancialAccountToken, transactionSeries, updated, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BookTransferResponse{token=$token, category=$category, created=$created, currency=$currency, events=$events, fromFinancialAccountToken=$fromFinancialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, toFinancialAccountToken=$toFinancialAccountToken, updated=$updated, additionalProperties=$additionalProperties}" + "BookTransferResponse{token=$token, category=$category, created=$created, currency=$currency, events=$events, externalResource=$externalResource, fromFinancialAccountToken=$fromFinancialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, toFinancialAccountToken=$toFinancialAccountToken, transactionSeries=$transactionSeries, updated=$updated, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt index 44ba40427..4883805f9 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt @@ -1549,12 +1549,15 @@ private constructor( @JvmField val APPROVED = of("APPROVED") + @JvmField val INSUFFICIENT_FUNDS = of("INSUFFICIENT_FUNDS") + @JvmStatic fun of(value: String) = DetailedResults(JsonField.of(value)) } /** An enum containing [DetailedResults]'s known values. */ enum class Known { - APPROVED + APPROVED, + INSUFFICIENT_FUNDS, } /** @@ -1568,6 +1571,7 @@ private constructor( */ enum class Value { APPROVED, + INSUFFICIENT_FUNDS, /** * An enum member indicating that [DetailedResults] was instantiated with an unknown * value. @@ -1585,6 +1589,7 @@ private constructor( fun value(): Value = when (this) { APPROVED -> Value.APPROVED + INSUFFICIENT_FUNDS -> Value.INSUFFICIENT_FUNDS else -> Value._UNKNOWN } @@ -1600,6 +1605,7 @@ private constructor( fun known(): Known = when (this) { APPROVED -> Known.APPROVED + INSUFFICIENT_FUNDS -> Known.INSUFFICIENT_FUNDS else -> throw LithicInvalidDataException("Unknown DetailedResults: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt index 8bd873c1e..87fcf8937 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt @@ -1816,12 +1816,15 @@ private constructor( @JvmField val APPROVED = of("APPROVED") + @JvmField val INSUFFICIENT_FUNDS = of("INSUFFICIENT_FUNDS") + @JvmStatic fun of(value: String) = DetailedResults(JsonField.of(value)) } /** An enum containing [DetailedResults]'s known values. */ enum class Known { - APPROVED + APPROVED, + INSUFFICIENT_FUNDS, } /** @@ -1835,6 +1838,7 @@ private constructor( */ enum class Value { APPROVED, + INSUFFICIENT_FUNDS, /** * An enum member indicating that [DetailedResults] was instantiated with an unknown * value. @@ -1852,6 +1856,7 @@ private constructor( fun value(): Value = when (this) { APPROVED -> Value.APPROVED + INSUFFICIENT_FUNDS -> Value.INSUFFICIENT_FUNDS else -> Value._UNKNOWN } @@ -1867,6 +1872,7 @@ private constructor( fun known(): Known = when (this) { APPROVED -> Known.APPROVED + INSUFFICIENT_FUNDS -> Known.INSUFFICIENT_FUNDS else -> throw LithicInvalidDataException("Unknown DetailedResults: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt index e781db9cf..ec1d7e20d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt @@ -36,6 +36,7 @@ private constructor( private val method: JsonField, private val methodAttributes: JsonField, private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, private val result: JsonField, private val settledAmount: JsonField, private val source: JsonField, @@ -76,6 +77,9 @@ private constructor( @JsonProperty("pending_amount") @ExcludeMissing pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), @JsonProperty("settled_amount") @ExcludeMissing @@ -104,6 +108,7 @@ private constructor( method, methodAttributes, pendingAmount, + relatedAccountTokens, result, settledAmount, source, @@ -204,6 +209,15 @@ private constructor( */ fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + /** + * Account tokens related to a payment transaction + * + * @throws LithicInvalidDataException 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 relatedAccountTokens(): RelatedAccountTokens = + relatedAccountTokens.getRequired("related_account_tokens") + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -358,6 +372,16 @@ private constructor( @ExcludeMissing fun _pendingAmount(): JsonField = pendingAmount + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + /** * Returns the raw JSON value of [result]. * @@ -445,6 +469,7 @@ private constructor( * .method() * .methodAttributes() * .pendingAmount() + * .relatedAccountTokens() * .result() * .settledAmount() * .source() @@ -471,6 +496,7 @@ private constructor( private var method: JsonField? = null private var methodAttributes: JsonField? = null private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null private var result: JsonField? = null private var settledAmount: JsonField? = null private var source: JsonField? = null @@ -494,6 +520,7 @@ private constructor( method = payment.method methodAttributes = payment.methodAttributes pendingAmount = payment.pendingAmount + relatedAccountTokens = payment.relatedAccountTokens result = payment.result settledAmount = payment.settledAmount source = payment.source @@ -677,6 +704,21 @@ private constructor( this.pendingAmount = pendingAmount } + /** Account tokens related to a payment transaction */ + fun relatedAccountTokens(relatedAccountTokens: RelatedAccountTokens) = + relatedAccountTokens(JsonField.of(relatedAccountTokens)) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [RelatedAccountTokens] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = apply { + this.relatedAccountTokens = relatedAccountTokens + } + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -819,6 +861,7 @@ private constructor( * .method() * .methodAttributes() * .pendingAmount() + * .relatedAccountTokens() * .result() * .settledAmount() * .source() @@ -843,6 +886,7 @@ private constructor( checkRequired("method", method), checkRequired("methodAttributes", methodAttributes), checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), checkRequired("result", result), checkRequired("settledAmount", settledAmount), checkRequired("source", source), @@ -873,6 +917,7 @@ private constructor( method().validate() methodAttributes().validate() pendingAmount() + relatedAccountTokens().validate() result().validate() settledAmount() source().validate() @@ -910,6 +955,7 @@ private constructor( (method.asKnown().getOrNull()?.validity() ?: 0) + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + (result.asKnown().getOrNull()?.validity() ?: 0) + (if (settledAmount.asKnown().isPresent) 1 else 0) + (source.asKnown().getOrNull()?.validity() ?: 0) + @@ -2763,6 +2809,231 @@ private constructor( "PaymentMethodAttributes{companyId=$companyId, receiptRoutingNumber=$receiptRoutingNumber, retries=$retries, returnReasonCode=$returnReasonCode, secCode=$secCode, traceNumbers=$traceNumbers, addenda=$addenda, additionalProperties=$additionalProperties}" } + /** Account tokens related to a payment transaction */ + class RelatedAccountTokens + private constructor( + private val accountToken: JsonField, + private val businessAccountToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("business_account_token") + @ExcludeMissing + businessAccountToken: JsonField = JsonMissing.of(), + ) : this(accountToken, businessAccountToken, mutableMapOf()) + + /** + * Globally unique identifier for the account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * Globally unique identifier for the business account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun businessAccountToken(): Optional = + businessAccountToken.getOptional("business_account_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [businessAccountToken]. + * + * Unlike [businessAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_account_token") + @ExcludeMissing + fun _businessAccountToken(): JsonField = businessAccountToken + + @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 [RelatedAccountTokens]. + * + * The following fields are required: + * ```java + * .accountToken() + * .businessAccountToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RelatedAccountTokens]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var businessAccountToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(relatedAccountTokens: RelatedAccountTokens) = apply { + accountToken = relatedAccountTokens.accountToken + businessAccountToken = relatedAccountTokens.businessAccountToken + additionalProperties = relatedAccountTokens.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the account */ + fun accountToken(accountToken: String?) = + accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = + accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Globally unique identifier for the business account */ + fun businessAccountToken(businessAccountToken: String?) = + businessAccountToken(JsonField.ofNullable(businessAccountToken)) + + /** + * Alias for calling [Builder.businessAccountToken] with + * `businessAccountToken.orElse(null)`. + */ + fun businessAccountToken(businessAccountToken: Optional) = + businessAccountToken(businessAccountToken.getOrNull()) + + /** + * Sets [Builder.businessAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.businessAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { + this.businessAccountToken = businessAccountToken + } + + 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 [RelatedAccountTokens]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .businessAccountToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RelatedAccountTokens = + RelatedAccountTokens( + checkRequired("accountToken", accountToken), + checkRequired("businessAccountToken", businessAccountToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RelatedAccountTokens = apply { + if (validated) { + return@apply + } + + accountToken() + businessAccountToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (accountToken.asKnown().isPresent) 1 else 0) + + (if (businessAccountToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RelatedAccountTokens && accountToken == other.accountToken && businessAccountToken == other.businessAccountToken && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accountToken, businessAccountToken, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RelatedAccountTokens{accountToken=$accountToken, businessAccountToken=$businessAccountToken, additionalProperties=$additionalProperties}" + } + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -3167,15 +3438,15 @@ private constructor( return true } - return /* spotless:off */ other is Payment && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && direction == other.direction && events == other.events && externalBankAccountToken == other.externalBankAccountToken && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Payment && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && direction == other.direction && events == other.events && externalBankAccountToken == other.externalBankAccountToken && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && relatedAccountTokens == other.relatedAccountTokens && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, direction, events, externalBankAccountToken, financialAccountToken, method, methodAttributes, pendingAmount, result, settledAmount, source, status, updated, userDefinedId, expectedReleaseDate, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, direction, events, externalBankAccountToken, financialAccountToken, method, methodAttributes, pendingAmount, relatedAccountTokens, result, settledAmount, source, status, updated, userDefinedId, expectedReleaseDate, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Payment{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, direction=$direction, events=$events, externalBankAccountToken=$externalBankAccountToken, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, userDefinedId=$userDefinedId, expectedReleaseDate=$expectedReleaseDate, additionalProperties=$additionalProperties}" + "Payment{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, direction=$direction, events=$events, externalBankAccountToken=$externalBankAccountToken, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, userDefinedId=$userDefinedId, expectedReleaseDate=$expectedReleaseDate, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt index e6d9f5c7b..fd89cc286 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt @@ -35,6 +35,7 @@ private constructor( private val method: JsonField, private val methodAttributes: JsonField, private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, private val result: JsonField, private val settledAmount: JsonField, private val source: JsonField, @@ -80,6 +81,9 @@ private constructor( @JsonProperty("pending_amount") @ExcludeMissing pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), @@ -115,6 +119,7 @@ private constructor( method, methodAttributes, pendingAmount, + relatedAccountTokens, result, settledAmount, source, @@ -140,6 +145,7 @@ private constructor( .method(method) .methodAttributes(methodAttributes) .pendingAmount(pendingAmount) + .relatedAccountTokens(relatedAccountTokens) .result(result) .settledAmount(settledAmount) .source(source) @@ -239,6 +245,15 @@ private constructor( */ fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + /** + * Account tokens related to a payment transaction + * + * @throws LithicInvalidDataException 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 relatedAccountTokens(): Payment.RelatedAccountTokens = + relatedAccountTokens.getRequired("related_account_tokens") + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -407,6 +422,16 @@ private constructor( @ExcludeMissing fun _pendingAmount(): JsonField = pendingAmount + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + /** * Returns the raw JSON value of [result]. * @@ -501,6 +526,7 @@ private constructor( * .method() * .methodAttributes() * .pendingAmount() + * .relatedAccountTokens() * .result() * .settledAmount() * .source() @@ -527,6 +553,7 @@ private constructor( private var method: JsonField? = null private var methodAttributes: JsonField? = null private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null private var result: JsonField? = null private var settledAmount: JsonField? = null private var source: JsonField? = null @@ -551,6 +578,7 @@ private constructor( method = paymentCreateResponse.method methodAttributes = paymentCreateResponse.methodAttributes pendingAmount = paymentCreateResponse.pendingAmount + relatedAccountTokens = paymentCreateResponse.relatedAccountTokens result = paymentCreateResponse.result settledAmount = paymentCreateResponse.settledAmount source = paymentCreateResponse.source @@ -738,6 +766,22 @@ private constructor( this.pendingAmount = pendingAmount } + /** Account tokens related to a payment transaction */ + fun relatedAccountTokens(relatedAccountTokens: Payment.RelatedAccountTokens) = + relatedAccountTokens(JsonField.of(relatedAccountTokens)) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [Payment.RelatedAccountTokens] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = + apply { + this.relatedAccountTokens = relatedAccountTokens + } + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -894,6 +938,7 @@ private constructor( * .method() * .methodAttributes() * .pendingAmount() + * .relatedAccountTokens() * .result() * .settledAmount() * .source() @@ -918,6 +963,7 @@ private constructor( checkRequired("method", method), checkRequired("methodAttributes", methodAttributes), checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), checkRequired("result", result), checkRequired("settledAmount", settledAmount), checkRequired("source", source), @@ -949,6 +995,7 @@ private constructor( method().validate() methodAttributes().validate() pendingAmount() + relatedAccountTokens().validate() result().validate() settledAmount() source().validate() @@ -987,6 +1034,7 @@ private constructor( (method.asKnown().getOrNull()?.validity() ?: 0) + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + (result.asKnown().getOrNull()?.validity() ?: 0) + (if (settledAmount.asKnown().isPresent) 1 else 0) + (source.asKnown().getOrNull()?.validity() ?: 0) + @@ -1001,15 +1049,15 @@ private constructor( return true } - return /* spotless:off */ other is PaymentCreateResponse && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && direction == other.direction && events == other.events && externalBankAccountToken == other.externalBankAccountToken && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && balance == other.balance && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PaymentCreateResponse && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && direction == other.direction && events == other.events && externalBankAccountToken == other.externalBankAccountToken && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && relatedAccountTokens == other.relatedAccountTokens && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && balance == other.balance && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, direction, events, externalBankAccountToken, financialAccountToken, method, methodAttributes, pendingAmount, result, settledAmount, source, status, updated, userDefinedId, expectedReleaseDate, balance, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, direction, events, externalBankAccountToken, financialAccountToken, method, methodAttributes, pendingAmount, relatedAccountTokens, result, settledAmount, source, status, updated, userDefinedId, expectedReleaseDate, balance, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PaymentCreateResponse{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, direction=$direction, events=$events, externalBankAccountToken=$externalBankAccountToken, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, userDefinedId=$userDefinedId, expectedReleaseDate=$expectedReleaseDate, balance=$balance, additionalProperties=$additionalProperties}" + "PaymentCreateResponse{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, direction=$direction, events=$events, externalBankAccountToken=$externalBankAccountToken, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, userDefinedId=$userDefinedId, expectedReleaseDate=$expectedReleaseDate, balance=$balance, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt index 5ac2f30ad..73dca3d3f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt @@ -35,6 +35,7 @@ private constructor( private val method: JsonField, private val methodAttributes: JsonField, private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, private val result: JsonField, private val settledAmount: JsonField, private val source: JsonField, @@ -80,6 +81,9 @@ private constructor( @JsonProperty("pending_amount") @ExcludeMissing pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), @@ -115,6 +119,7 @@ private constructor( method, methodAttributes, pendingAmount, + relatedAccountTokens, result, settledAmount, source, @@ -140,6 +145,7 @@ private constructor( .method(method) .methodAttributes(methodAttributes) .pendingAmount(pendingAmount) + .relatedAccountTokens(relatedAccountTokens) .result(result) .settledAmount(settledAmount) .source(source) @@ -239,6 +245,15 @@ private constructor( */ fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + /** + * Account tokens related to a payment transaction + * + * @throws LithicInvalidDataException 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 relatedAccountTokens(): Payment.RelatedAccountTokens = + relatedAccountTokens.getRequired("related_account_tokens") + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -407,6 +422,16 @@ private constructor( @ExcludeMissing fun _pendingAmount(): JsonField = pendingAmount + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + /** * Returns the raw JSON value of [result]. * @@ -501,6 +526,7 @@ private constructor( * .method() * .methodAttributes() * .pendingAmount() + * .relatedAccountTokens() * .result() * .settledAmount() * .source() @@ -527,6 +553,7 @@ private constructor( private var method: JsonField? = null private var methodAttributes: JsonField? = null private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null private var result: JsonField? = null private var settledAmount: JsonField? = null private var source: JsonField? = null @@ -551,6 +578,7 @@ private constructor( method = paymentRetryResponse.method methodAttributes = paymentRetryResponse.methodAttributes pendingAmount = paymentRetryResponse.pendingAmount + relatedAccountTokens = paymentRetryResponse.relatedAccountTokens result = paymentRetryResponse.result settledAmount = paymentRetryResponse.settledAmount source = paymentRetryResponse.source @@ -738,6 +766,22 @@ private constructor( this.pendingAmount = pendingAmount } + /** Account tokens related to a payment transaction */ + fun relatedAccountTokens(relatedAccountTokens: Payment.RelatedAccountTokens) = + relatedAccountTokens(JsonField.of(relatedAccountTokens)) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [Payment.RelatedAccountTokens] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = + apply { + this.relatedAccountTokens = relatedAccountTokens + } + /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. @@ -894,6 +938,7 @@ private constructor( * .method() * .methodAttributes() * .pendingAmount() + * .relatedAccountTokens() * .result() * .settledAmount() * .source() @@ -918,6 +963,7 @@ private constructor( checkRequired("method", method), checkRequired("methodAttributes", methodAttributes), checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), checkRequired("result", result), checkRequired("settledAmount", settledAmount), checkRequired("source", source), @@ -949,6 +995,7 @@ private constructor( method().validate() methodAttributes().validate() pendingAmount() + relatedAccountTokens().validate() result().validate() settledAmount() source().validate() @@ -987,6 +1034,7 @@ private constructor( (method.asKnown().getOrNull()?.validity() ?: 0) + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + (result.asKnown().getOrNull()?.validity() ?: 0) + (if (settledAmount.asKnown().isPresent) 1 else 0) + (source.asKnown().getOrNull()?.validity() ?: 0) + @@ -1001,15 +1049,15 @@ private constructor( return true } - return /* spotless:off */ other is PaymentRetryResponse && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && direction == other.direction && events == other.events && externalBankAccountToken == other.externalBankAccountToken && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && balance == other.balance && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PaymentRetryResponse && token == other.token && category == other.category && created == other.created && currency == other.currency && descriptor == other.descriptor && direction == other.direction && events == other.events && externalBankAccountToken == other.externalBankAccountToken && financialAccountToken == other.financialAccountToken && method == other.method && methodAttributes == other.methodAttributes && pendingAmount == other.pendingAmount && relatedAccountTokens == other.relatedAccountTokens && result == other.result && settledAmount == other.settledAmount && source == other.source && status == other.status && updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && balance == other.balance && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, direction, events, externalBankAccountToken, financialAccountToken, method, methodAttributes, pendingAmount, result, settledAmount, source, status, updated, userDefinedId, expectedReleaseDate, balance, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, descriptor, direction, events, externalBankAccountToken, financialAccountToken, method, methodAttributes, pendingAmount, relatedAccountTokens, result, settledAmount, source, status, updated, userDefinedId, expectedReleaseDate, balance, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PaymentRetryResponse{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, direction=$direction, events=$events, externalBankAccountToken=$externalBankAccountToken, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, userDefinedId=$userDefinedId, expectedReleaseDate=$expectedReleaseDate, balance=$balance, additionalProperties=$additionalProperties}" + "PaymentRetryResponse{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, direction=$direction, events=$events, externalBankAccountToken=$externalBankAccountToken, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, userDefinedId=$userDefinedId, expectedReleaseDate=$expectedReleaseDate, balance=$balance, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountActivityServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountActivityServiceAsync.kt new file mode 100644 index 000000000..d549d1e7b --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountActivityServiceAsync.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.AccountActivityListPageAsync +import com.lithic.api.models.AccountActivityListParams +import com.lithic.api.models.AccountActivityRetrieveTransactionParams +import com.lithic.api.models.AccountActivityRetrieveTransactionResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AccountActivityServiceAsync { + + /** + * 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): AccountActivityServiceAsync + + /** Retrieve a list of transactions across all public accounts. */ + fun list(): CompletableFuture = + list(AccountActivityListParams.none()) + + /** @see list */ + fun list( + params: AccountActivityListParams = AccountActivityListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: AccountActivityListParams = AccountActivityListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AccountActivityListParams.none(), requestOptions) + + /** Retrieve a single transaction */ + fun retrieveTransaction( + transactionToken: String + ): CompletableFuture = + retrieveTransaction(transactionToken, AccountActivityRetrieveTransactionParams.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveTransaction( + params.toBuilder().transactionToken(transactionToken).build(), + requestOptions, + ) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + ): CompletableFuture = + retrieveTransaction(transactionToken, params, RequestOptions.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveTransaction */ + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams + ): CompletableFuture = + retrieveTransaction(params, RequestOptions.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveTransaction( + transactionToken, + AccountActivityRetrieveTransactionParams.none(), + requestOptions, + ) + + /** + * A view of [AccountActivityServiceAsync] 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 + ): AccountActivityServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/account_activity`, but is otherwise the same as + * [AccountActivityServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(AccountActivityListParams.none()) + + /** @see list */ + fun list( + params: AccountActivityListParams = AccountActivityListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: AccountActivityListParams = AccountActivityListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AccountActivityListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/account_activity/{transaction_token}`, but is + * otherwise the same as [AccountActivityServiceAsync.retrieveTransaction]. + */ + fun retrieveTransaction( + transactionToken: String + ): CompletableFuture> = + retrieveTransaction(transactionToken, AccountActivityRetrieveTransactionParams.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveTransaction( + params.toBuilder().transactionToken(transactionToken).build(), + requestOptions, + ) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + ): CompletableFuture> = + retrieveTransaction(transactionToken, params, RequestOptions.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveTransaction */ + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams + ): CompletableFuture> = + retrieveTransaction(params, RequestOptions.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveTransaction( + transactionToken, + AccountActivityRetrieveTransactionParams.none(), + requestOptions, + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountActivityServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountActivityServiceAsyncImpl.kt new file mode 100644 index 000000000..5ae8df1c8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AccountActivityServiceAsyncImpl.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepareAsync +import com.lithic.api.models.AccountActivityListPageAsync +import com.lithic.api.models.AccountActivityListPageResponse +import com.lithic.api.models.AccountActivityListParams +import com.lithic.api.models.AccountActivityRetrieveTransactionParams +import com.lithic.api.models.AccountActivityRetrieveTransactionResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AccountActivityServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : AccountActivityServiceAsync { + + private val withRawResponse: AccountActivityServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AccountActivityServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): AccountActivityServiceAsync = + AccountActivityServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: AccountActivityListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/account_activity + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/account_activity/{transaction_token} + withRawResponse().retrieveTransaction(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccountActivityServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AccountActivityServiceAsync.WithRawResponse = + AccountActivityServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AccountActivityListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "account_activity") + .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 { + AccountActivityListPageAsync.builder() + .service(AccountActivityServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val retrieveTransactionHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("transactionToken", params.transactionToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "account_activity", 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 { retrieveTransactionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountActivityService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountActivityService.kt new file mode 100644 index 000000000..1bcd9d9ae --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountActivityService.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.AccountActivityListPage +import com.lithic.api.models.AccountActivityListParams +import com.lithic.api.models.AccountActivityRetrieveTransactionParams +import com.lithic.api.models.AccountActivityRetrieveTransactionResponse +import java.util.function.Consumer + +interface AccountActivityService { + + /** + * 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): AccountActivityService + + /** Retrieve a list of transactions across all public accounts. */ + fun list(): AccountActivityListPage = list(AccountActivityListParams.none()) + + /** @see list */ + fun list( + params: AccountActivityListParams = AccountActivityListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccountActivityListPage + + /** @see list */ + fun list( + params: AccountActivityListParams = AccountActivityListParams.none() + ): AccountActivityListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): AccountActivityListPage = + list(AccountActivityListParams.none(), requestOptions) + + /** Retrieve a single transaction */ + fun retrieveTransaction(transactionToken: String): AccountActivityRetrieveTransactionResponse = + retrieveTransaction(transactionToken, AccountActivityRetrieveTransactionParams.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccountActivityRetrieveTransactionResponse = + retrieveTransaction( + params.toBuilder().transactionToken(transactionToken).build(), + requestOptions, + ) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + ): AccountActivityRetrieveTransactionResponse = + retrieveTransaction(transactionToken, params, RequestOptions.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AccountActivityRetrieveTransactionResponse + + /** @see retrieveTransaction */ + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams + ): AccountActivityRetrieveTransactionResponse = + retrieveTransaction(params, RequestOptions.none()) + + /** @see retrieveTransaction */ + fun retrieveTransaction( + transactionToken: String, + requestOptions: RequestOptions, + ): AccountActivityRetrieveTransactionResponse = + retrieveTransaction( + transactionToken, + AccountActivityRetrieveTransactionParams.none(), + requestOptions, + ) + + /** + * A view of [AccountActivityService] 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 + ): AccountActivityService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/account_activity`, but is otherwise the same as + * [AccountActivityService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = + list(AccountActivityListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: AccountActivityListParams = AccountActivityListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: AccountActivityListParams = AccountActivityListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(AccountActivityListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/account_activity/{transaction_token}`, but is + * otherwise the same as [AccountActivityService.retrieveTransaction]. + */ + @MustBeClosed + fun retrieveTransaction( + transactionToken: String + ): HttpResponseFor = + retrieveTransaction(transactionToken, AccountActivityRetrieveTransactionParams.none()) + + /** @see retrieveTransaction */ + @MustBeClosed + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveTransaction( + params.toBuilder().transactionToken(transactionToken).build(), + requestOptions, + ) + + /** @see retrieveTransaction */ + @MustBeClosed + fun retrieveTransaction( + transactionToken: String, + params: AccountActivityRetrieveTransactionParams = + AccountActivityRetrieveTransactionParams.none(), + ): HttpResponseFor = + retrieveTransaction(transactionToken, params, RequestOptions.none()) + + /** @see retrieveTransaction */ + @MustBeClosed + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveTransaction */ + @MustBeClosed + fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams + ): HttpResponseFor = + retrieveTransaction(params, RequestOptions.none()) + + /** @see retrieveTransaction */ + @MustBeClosed + fun retrieveTransaction( + transactionToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveTransaction( + transactionToken, + AccountActivityRetrieveTransactionParams.none(), + requestOptions, + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountActivityServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountActivityServiceImpl.kt new file mode 100644 index 000000000..4b205d1ae --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AccountActivityServiceImpl.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepare +import com.lithic.api.models.AccountActivityListPage +import com.lithic.api.models.AccountActivityListPageResponse +import com.lithic.api.models.AccountActivityListParams +import com.lithic.api.models.AccountActivityRetrieveTransactionParams +import com.lithic.api.models.AccountActivityRetrieveTransactionResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AccountActivityServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AccountActivityService { + + private val withRawResponse: AccountActivityService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AccountActivityService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccountActivityService = + AccountActivityServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: AccountActivityListParams, + requestOptions: RequestOptions, + ): AccountActivityListPage = + // get /v1/account_activity + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions, + ): AccountActivityRetrieveTransactionResponse = + // get /v1/account_activity/{transaction_token} + withRawResponse().retrieveTransaction(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccountActivityService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AccountActivityService.WithRawResponse = + AccountActivityServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AccountActivityListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "account_activity") + .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 { + AccountActivityListPage.builder() + .service(AccountActivityServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val retrieveTransactionHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveTransaction( + params: AccountActivityRetrieveTransactionParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("transactionToken", params.transactionToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "account_activity", 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 { retrieveTransactionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListPageResponseTest.kt new file mode 100644 index 000000000..116f413d3 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListPageResponseTest.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountActivityListPageResponseTest { + + @Test + fun create() { + val accountActivityListPageResponse = + AccountActivityListPageResponse.builder() + .addData( + AccountActivityListResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.FinancialTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes + .CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result( + AccountActivityListResponse.FinancialTransaction.TransactionResult + .APPROVED + ) + .settledAmount(200L) + .status( + AccountActivityListResponse.FinancialTransaction.TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .hasMore(true) + .build() + + assertThat(accountActivityListPageResponse.data().getOrNull()) + .containsExactly( + AccountActivityListResponse.ofFinancialTransaction( + AccountActivityListResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.FinancialTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes + .CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result( + AccountActivityListResponse.FinancialTransaction.TransactionResult + .APPROVED + ) + .settledAmount(200L) + .status( + AccountActivityListResponse.FinancialTransaction.TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + assertThat(accountActivityListPageResponse.hasMore()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListPageResponse = + AccountActivityListPageResponse.builder() + .addData( + AccountActivityListResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.FinancialTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes + .CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result( + AccountActivityListResponse.FinancialTransaction.TransactionResult + .APPROVED + ) + .settledAmount(200L) + .status( + AccountActivityListResponse.FinancialTransaction.TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .hasMore(true) + .build() + + val roundtrippedAccountActivityListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListPageResponse) + .isEqualTo(accountActivityListPageResponse) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListParamsTest.kt new file mode 100644 index 000000000..900db4ba1 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountActivityListParamsTest { + + @Test + fun create() { + AccountActivityListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(AccountActivityListParams.TransactionCategory.ACH) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("ending_before") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(1L) + .addResult(AccountActivityListParams.Result.APPROVED) + .startingAfter("starting_after") + .addStatus(AccountActivityListParams.Status.DECLINED) + .build() + } + + @Test + fun queryParams() { + val params = + AccountActivityListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(AccountActivityListParams.TransactionCategory.ACH) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("ending_before") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(1L) + .addResult(AccountActivityListParams.Result.APPROVED) + .startingAfter("starting_after") + .addStatus(AccountActivityListParams.Status.DECLINED) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("begin", "2019-12-27T18:11:19.117Z") + .put("business_account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("category", "ACH") + .put("end", "2019-12-27T18:11:19.117Z") + .put("ending_before", "ending_before") + .put("financial_account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("page_size", "1") + .put("result", listOf("APPROVED").joinToString(",")) + .put("starting_after", "starting_after") + .put("status", listOf("DECLINED").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = AccountActivityListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt new file mode 100644 index 000000000..03158aa1d --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt @@ -0,0 +1,1090 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class AccountActivityListResponseTest { + + @Test + fun ofFinancialTransaction() { + val financialTransaction = + AccountActivityListResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(AccountActivityListResponse.FinancialTransaction.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes.CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result(AccountActivityListResponse.FinancialTransaction.TransactionResult.APPROVED) + .settledAmount(200L) + .status(AccountActivityListResponse.FinancialTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val accountActivityListResponse = + AccountActivityListResponse.ofFinancialTransaction(financialTransaction) + + assertThat(accountActivityListResponse.financialTransaction()) + .contains(financialTransaction) + assertThat(accountActivityListResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityListResponse.cardTransaction()).isEmpty + assertThat(accountActivityListResponse.paymentTransaction()).isEmpty + assertThat(accountActivityListResponse.externalPayment()).isEmpty + assertThat(accountActivityListResponse.managementOperationTransaction()).isEmpty + } + + @Test + fun ofFinancialTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListResponse = + AccountActivityListResponse.ofFinancialTransaction( + AccountActivityListResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.FinancialTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes.CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result( + AccountActivityListResponse.FinancialTransaction.TransactionResult.APPROVED + ) + .settledAmount(200L) + .status( + AccountActivityListResponse.FinancialTransaction.TransactionStatus.PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedAccountActivityListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListResponse).isEqualTo(accountActivityListResponse) + } + + @Test + fun ofBookTransferTransaction() { + val bookTransferTransaction = + AccountActivityListResponse.BookTransferTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.BookTransferTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.BookTransferTransaction.TransactionFamilyTypes.CARD + ) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result( + AccountActivityListResponse.BookTransferTransaction.TransactionResult.APPROVED + ) + .settledAmount(500L) + .status( + AccountActivityListResponse.BookTransferTransaction.TransactionStatus.PENDING + ) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + AccountActivityListResponse.BookTransferTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .build() + + val accountActivityListResponse = + AccountActivityListResponse.ofBookTransferTransaction(bookTransferTransaction) + + assertThat(accountActivityListResponse.financialTransaction()).isEmpty + assertThat(accountActivityListResponse.bookTransferTransaction()) + .contains(bookTransferTransaction) + assertThat(accountActivityListResponse.cardTransaction()).isEmpty + assertThat(accountActivityListResponse.paymentTransaction()).isEmpty + assertThat(accountActivityListResponse.externalPayment()).isEmpty + assertThat(accountActivityListResponse.managementOperationTransaction()).isEmpty + } + + @Test + fun ofBookTransferTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListResponse = + AccountActivityListResponse.ofBookTransferTransaction( + AccountActivityListResponse.BookTransferTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.BookTransferTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.BookTransferTransaction.TransactionFamilyTypes + .CARD + ) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result( + AccountActivityListResponse.BookTransferTransaction.TransactionResult + .APPROVED + ) + .settledAmount(500L) + .status( + AccountActivityListResponse.BookTransferTransaction.TransactionStatus + .PENDING + ) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + AccountActivityListResponse.BookTransferTransaction.TransactionSeries + .builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .build() + ) + + val roundtrippedAccountActivityListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListResponse).isEqualTo(accountActivityListResponse) + } + + @Test + fun ofCardTransaction() { + val cardTransaction = + AccountActivityListResponse.CardTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("bd5e5649-1be8-4117-9bc5-3268258d1417") + .acquirerFee(0L) + .acquirerReferenceNumber("12345678987654321234567") + .amount(1000L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(-1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1000L) + .authorizationCode("123456") + .avs(Transaction.Avs.builder().address("address").zipcode("zipcode").build()) + .cardToken("19c22c47-7a75-43ee-9891-595419830f7e") + .cardholderAuthentication( + Transaction.CardholderAuthentication.builder() + .threeDSVersion("2") + .acquirerExemption( + Transaction.CardholderAuthentication.AcquirerExemption.NONE + ) + .authenticationResult( + Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + Transaction.CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .verificationAttempted( + Transaction.CardholderAuthentication.VerificationAttempted.NONE + ) + .verificationResult( + Transaction.CardholderAuthentication.VerificationResult.FRICTIONLESS + ) + .authenticationMethod( + Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Transaction.Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(1000L) + .merchantAuthorizationAmount(1000L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(0L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder( + Transaction.Pos.PosEntryMode.Cardholder.DEFERRED_BILLING + ) + .pan(Transaction.Pos.PosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator(Transaction.Pos.PosTerminal.Operator.ADMINISTRATIVE) + .partialApprovalCapable(true) + .pinCapability(Transaction.Pos.PosTerminal.PinCapability.CAPABLE) + .type(Transaction.Pos.PosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(1000L) + .status(Transaction.Status.PENDING) + .tokenInfo( + Transaction.TokenInfo.builder() + .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("0c2adae9-f535-4505-8c35-421dad9bd0b6") + .amount(1000L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts.Cardholder + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts.Merchant + .builder() + .amount(1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts.Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-09-26T21:14:28.637Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber("acquirer_reference_number") + .retrievalReferenceNumber("retrieval_reference_number") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() + .banknetReferenceNumber("banknet_reference_number") + .originalBanknetReferenceNumber( + "original_banknet_reference_number" + ) + .originalSwitchSerialNumber("original_switch_serial_number") + .switchSerialNumber("switch_serial_number") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult.APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.CLEARING) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .family(AccountActivityListResponse.CardTransaction.TransactionFamilyTypes.CARD) + .build() + + val accountActivityListResponse = + AccountActivityListResponse.ofCardTransaction(cardTransaction) + + assertThat(accountActivityListResponse.financialTransaction()).isEmpty + assertThat(accountActivityListResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityListResponse.cardTransaction()).contains(cardTransaction) + assertThat(accountActivityListResponse.paymentTransaction()).isEmpty + assertThat(accountActivityListResponse.externalPayment()).isEmpty + assertThat(accountActivityListResponse.managementOperationTransaction()).isEmpty + } + + @Test + fun ofCardTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListResponse = + AccountActivityListResponse.ofCardTransaction( + AccountActivityListResponse.CardTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("bd5e5649-1be8-4117-9bc5-3268258d1417") + .acquirerFee(0L) + .acquirerReferenceNumber("12345678987654321234567") + .amount(1000L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(-1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1000L) + .authorizationCode("123456") + .avs(Transaction.Avs.builder().address("address").zipcode("zipcode").build()) + .cardToken("19c22c47-7a75-43ee-9891-595419830f7e") + .cardholderAuthentication( + Transaction.CardholderAuthentication.builder() + .threeDSVersion("2") + .acquirerExemption( + Transaction.CardholderAuthentication.AcquirerExemption.NONE + ) + .authenticationResult( + Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + Transaction.CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + Transaction.CardholderAuthentication.LiabilityShift + ._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .verificationAttempted( + Transaction.CardholderAuthentication.VerificationAttempted.NONE + ) + .verificationResult( + Transaction.CardholderAuthentication.VerificationResult.FRICTIONLESS + ) + .authenticationMethod( + Transaction.CardholderAuthentication.AuthenticationMethod + .FRICTIONLESS + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Transaction.Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(1000L) + .merchantAuthorizationAmount(1000L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(0L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder( + Transaction.Pos.PosEntryMode.Cardholder.DEFERRED_BILLING + ) + .pan(Transaction.Pos.PosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator(Transaction.Pos.PosTerminal.Operator.ADMINISTRATIVE) + .partialApprovalCapable(true) + .pinCapability( + Transaction.Pos.PosTerminal.PinCapability.CAPABLE + ) + .type(Transaction.Pos.PosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(1000L) + .status(Transaction.Status.PENDING) + .tokenInfo( + Transaction.TokenInfo.builder() + .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("0c2adae9-f535-4505-8c35-421dad9bd0b6") + .amount(1000L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts + .Cardholder + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts + .Merchant + .builder() + .amount(1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts + .Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-09-26T21:14:28.637Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber("acquirer_reference_number") + .retrievalReferenceNumber("retrieval_reference_number") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard + .builder() + .banknetReferenceNumber("banknet_reference_number") + .originalBanknetReferenceNumber( + "original_banknet_reference_number" + ) + .originalSwitchSerialNumber( + "original_switch_serial_number" + ) + .switchSerialNumber("switch_serial_number") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult + .APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.CLEARING) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .family(AccountActivityListResponse.CardTransaction.TransactionFamilyTypes.CARD) + .build() + ) + + val roundtrippedAccountActivityListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListResponse).isEqualTo(accountActivityListResponse) + } + + @Test + fun ofPaymentTransaction() { + val paymentTransaction = + AccountActivityListResponse.PaymentTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(AccountActivityListResponse.PaymentTransaction.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .descriptor("descriptor") + .direction(AccountActivityListResponse.PaymentTransaction.Direction.CREDIT) + .addEvent(JsonValue.from(mapOf())) + .family(AccountActivityListResponse.PaymentTransaction.TransactionFamilyTypes.CARD) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .method(AccountActivityListResponse.PaymentTransaction.Method.ACH_NEXT_DAY) + .methodAttributes( + AccountActivityListResponse.PaymentTransaction.MethodAttributes + .AchMethodAttributes + .builder() + .secCode( + AccountActivityListResponse.PaymentTransaction.MethodAttributes + .AchMethodAttributes + .SecCode + .CCD + ) + .addenda("addenda") + .companyId("company_id") + .receiptRoutingNumber("receipt_routing_number") + .retries(0L) + .returnReasonCode("return_reason_code") + .addTraceNumber("string") + .build() + ) + .pendingAmount(200L) + .relatedAccountTokens( + AccountActivityListResponse.PaymentTransaction.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(AccountActivityListResponse.PaymentTransaction.TransactionResult.APPROVED) + .settledAmount(500L) + .source(AccountActivityListResponse.PaymentTransaction.Source.LITHIC) + .status(AccountActivityListResponse.PaymentTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userDefinedId("user_defined_id") + .build() + + val accountActivityListResponse = + AccountActivityListResponse.ofPaymentTransaction(paymentTransaction) + + assertThat(accountActivityListResponse.financialTransaction()).isEmpty + assertThat(accountActivityListResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityListResponse.cardTransaction()).isEmpty + assertThat(accountActivityListResponse.paymentTransaction()).contains(paymentTransaction) + assertThat(accountActivityListResponse.externalPayment()).isEmpty + assertThat(accountActivityListResponse.managementOperationTransaction()).isEmpty + } + + @Test + fun ofPaymentTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListResponse = + AccountActivityListResponse.ofPaymentTransaction( + AccountActivityListResponse.PaymentTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityListResponse.PaymentTransaction.TransactionCategory.ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .descriptor("descriptor") + .direction(AccountActivityListResponse.PaymentTransaction.Direction.CREDIT) + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityListResponse.PaymentTransaction.TransactionFamilyTypes.CARD + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .method(AccountActivityListResponse.PaymentTransaction.Method.ACH_NEXT_DAY) + .methodAttributes( + AccountActivityListResponse.PaymentTransaction.MethodAttributes + .AchMethodAttributes + .builder() + .secCode( + AccountActivityListResponse.PaymentTransaction.MethodAttributes + .AchMethodAttributes + .SecCode + .CCD + ) + .addenda("addenda") + .companyId("company_id") + .receiptRoutingNumber("receipt_routing_number") + .retries(0L) + .returnReasonCode("return_reason_code") + .addTraceNumber("string") + .build() + ) + .pendingAmount(200L) + .relatedAccountTokens( + AccountActivityListResponse.PaymentTransaction.RelatedAccountTokens + .builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result( + AccountActivityListResponse.PaymentTransaction.TransactionResult.APPROVED + ) + .settledAmount(500L) + .source(AccountActivityListResponse.PaymentTransaction.Source.LITHIC) + .status( + AccountActivityListResponse.PaymentTransaction.TransactionStatus.PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userDefinedId("user_defined_id") + .build() + ) + + val roundtrippedAccountActivityListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListResponse).isEqualTo(accountActivityListResponse) + } + + @Test + fun ofExternalPayment() { + val externalPayment = + ExternalPayment.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ExternalPayment.TransactionFamilyTypes.CARD) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .build() + + val accountActivityListResponse = + AccountActivityListResponse.ofExternalPayment(externalPayment) + + assertThat(accountActivityListResponse.financialTransaction()).isEmpty + assertThat(accountActivityListResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityListResponse.cardTransaction()).isEmpty + assertThat(accountActivityListResponse.paymentTransaction()).isEmpty + assertThat(accountActivityListResponse.externalPayment()).contains(externalPayment) + assertThat(accountActivityListResponse.managementOperationTransaction()).isEmpty + } + + @Test + fun ofExternalPaymentRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListResponse = + AccountActivityListResponse.ofExternalPayment( + ExternalPayment.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ExternalPayment.TransactionFamilyTypes.CARD) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .build() + ) + + val roundtrippedAccountActivityListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListResponse).isEqualTo(accountActivityListResponse) + } + + @Test + fun ofManagementOperationTransaction() { + val managementOperationTransaction = + ManagementOperationTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ManagementOperationTransaction.TransactionFamilyTypes.CARD) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .build() + + val accountActivityListResponse = + AccountActivityListResponse.ofManagementOperationTransaction( + managementOperationTransaction + ) + + assertThat(accountActivityListResponse.financialTransaction()).isEmpty + assertThat(accountActivityListResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityListResponse.cardTransaction()).isEmpty + assertThat(accountActivityListResponse.paymentTransaction()).isEmpty + assertThat(accountActivityListResponse.externalPayment()).isEmpty + assertThat(accountActivityListResponse.managementOperationTransaction()) + .contains(managementOperationTransaction) + } + + @Test + fun ofManagementOperationTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityListResponse = + AccountActivityListResponse.ofManagementOperationTransaction( + ManagementOperationTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ManagementOperationTransaction.TransactionFamilyTypes.CARD) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category( + ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE + ) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent + .DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .build() + ) + + val roundtrippedAccountActivityListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityListResponse).isEqualTo(accountActivityListResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val accountActivityListResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { accountActivityListResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionParamsTest.kt new file mode 100644 index 000000000..086d17e69 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountActivityRetrieveTransactionParamsTest { + + @Test + fun create() { + AccountActivityRetrieveTransactionParams.builder() + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + AccountActivityRetrieveTransactionParams.builder() + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt new file mode 100644 index 000000000..c213323fd --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt @@ -0,0 +1,1200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class AccountActivityRetrieveTransactionResponseTest { + + @Test + fun ofFinancialTransaction() { + val financialTransaction = + AccountActivityRetrieveTransactionResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionCategory + .ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionFamilyTypes + .CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionResult + .APPROVED + ) + .settledAmount(200L) + .status( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofFinancialTransaction(financialTransaction) + + assertThat(accountActivityRetrieveTransactionResponse.financialTransaction()) + .contains(financialTransaction) + assertThat(accountActivityRetrieveTransactionResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.cardTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.paymentTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.externalPayment()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.managementOperationTransaction()) + .isEmpty + } + + @Test + fun ofFinancialTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofFinancialTransaction( + AccountActivityRetrieveTransactionResponse.FinancialTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionCategory + .ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .descriptor("descriptor") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionFamilyTypes + .CARD + ) + .financialAccountToken("0cc87075-57cf-4607-8722-f42e2cb2c0cd") + .pendingAmount(500L) + .result( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionResult + .APPROVED + ) + .settledAmount(200L) + .status( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedAccountActivityRetrieveTransactionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityRetrieveTransactionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityRetrieveTransactionResponse) + .isEqualTo(accountActivityRetrieveTransactionResponse) + } + + @Test + fun ofBookTransferTransaction() { + val bookTransferTransaction = + AccountActivityRetrieveTransactionResponse.BookTransferTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionCategory + .ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionFamilyTypes + .CARD + ) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionResult + .APPROVED + ) + .settledAmount(500L) + .status( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionStatus + .PENDING + ) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionSeries + .builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .build() + + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofBookTransferTransaction( + bookTransferTransaction + ) + + assertThat(accountActivityRetrieveTransactionResponse.financialTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.bookTransferTransaction()) + .contains(bookTransferTransaction) + assertThat(accountActivityRetrieveTransactionResponse.cardTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.paymentTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.externalPayment()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.managementOperationTransaction()) + .isEmpty + } + + @Test + fun ofBookTransferTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofBookTransferTransaction( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionCategory + .ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionFamilyTypes + .CARD + ) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionResult + .APPROVED + ) + .settledAmount(500L) + .status( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionStatus + .PENDING + ) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .TransactionSeries + .builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .build() + ) + + val roundtrippedAccountActivityRetrieveTransactionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityRetrieveTransactionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityRetrieveTransactionResponse) + .isEqualTo(accountActivityRetrieveTransactionResponse) + } + + @Test + fun ofCardTransaction() { + val cardTransaction = + AccountActivityRetrieveTransactionResponse.CardTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("bd5e5649-1be8-4117-9bc5-3268258d1417") + .acquirerFee(0L) + .acquirerReferenceNumber("12345678987654321234567") + .amount(1000L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(-1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1000L) + .authorizationCode("123456") + .avs(Transaction.Avs.builder().address("address").zipcode("zipcode").build()) + .cardToken("19c22c47-7a75-43ee-9891-595419830f7e") + .cardholderAuthentication( + Transaction.CardholderAuthentication.builder() + .threeDSVersion("2") + .acquirerExemption( + Transaction.CardholderAuthentication.AcquirerExemption.NONE + ) + .authenticationResult( + Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + Transaction.CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .verificationAttempted( + Transaction.CardholderAuthentication.VerificationAttempted.NONE + ) + .verificationResult( + Transaction.CardholderAuthentication.VerificationResult.FRICTIONLESS + ) + .authenticationMethod( + Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Transaction.Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(1000L) + .merchantAuthorizationAmount(1000L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(0L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder( + Transaction.Pos.PosEntryMode.Cardholder.DEFERRED_BILLING + ) + .pan(Transaction.Pos.PosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator(Transaction.Pos.PosTerminal.Operator.ADMINISTRATIVE) + .partialApprovalCapable(true) + .pinCapability(Transaction.Pos.PosTerminal.PinCapability.CAPABLE) + .type(Transaction.Pos.PosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(1000L) + .status(Transaction.Status.PENDING) + .tokenInfo( + Transaction.TokenInfo.builder() + .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("0c2adae9-f535-4505-8c35-421dad9bd0b6") + .amount(1000L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts.Cardholder + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts.Merchant + .builder() + .amount(1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts.Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-09-26T21:14:28.637Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber("acquirer_reference_number") + .retrievalReferenceNumber("retrieval_reference_number") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() + .banknetReferenceNumber("banknet_reference_number") + .originalBanknetReferenceNumber( + "original_banknet_reference_number" + ) + .originalSwitchSerialNumber("original_switch_serial_number") + .switchSerialNumber("switch_serial_number") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult.APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.CLEARING) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .family( + AccountActivityRetrieveTransactionResponse.CardTransaction + .TransactionFamilyTypes + .CARD + ) + .build() + + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofCardTransaction(cardTransaction) + + assertThat(accountActivityRetrieveTransactionResponse.financialTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.cardTransaction()) + .contains(cardTransaction) + assertThat(accountActivityRetrieveTransactionResponse.paymentTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.externalPayment()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.managementOperationTransaction()) + .isEmpty + } + + @Test + fun ofCardTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofCardTransaction( + AccountActivityRetrieveTransactionResponse.CardTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("bd5e5649-1be8-4117-9bc5-3268258d1417") + .acquirerFee(0L) + .acquirerReferenceNumber("12345678987654321234567") + .amount(1000L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(-1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(-1000L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1000L) + .authorizationCode("123456") + .avs(Transaction.Avs.builder().address("address").zipcode("zipcode").build()) + .cardToken("19c22c47-7a75-43ee-9891-595419830f7e") + .cardholderAuthentication( + Transaction.CardholderAuthentication.builder() + .threeDSVersion("2") + .acquirerExemption( + Transaction.CardholderAuthentication.AcquirerExemption.NONE + ) + .authenticationResult( + Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + Transaction.CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + Transaction.CardholderAuthentication.LiabilityShift + ._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .verificationAttempted( + Transaction.CardholderAuthentication.VerificationAttempted.NONE + ) + .verificationResult( + Transaction.CardholderAuthentication.VerificationResult.FRICTIONLESS + ) + .authenticationMethod( + Transaction.CardholderAuthentication.AuthenticationMethod + .FRICTIONLESS + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Transaction.Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(1000L) + .merchantAuthorizationAmount(1000L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(0L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder( + Transaction.Pos.PosEntryMode.Cardholder.DEFERRED_BILLING + ) + .pan(Transaction.Pos.PosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator(Transaction.Pos.PosTerminal.Operator.ADMINISTRATIVE) + .partialApprovalCapable(true) + .pinCapability( + Transaction.Pos.PosTerminal.PinCapability.CAPABLE + ) + .type(Transaction.Pos.PosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(1000L) + .status(Transaction.Status.PENDING) + .tokenInfo( + Transaction.TokenInfo.builder() + .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("0c2adae9-f535-4505-8c35-421dad9bd0b6") + .amount(1000L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts + .Cardholder + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts + .Merchant + .builder() + .amount(1000L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts + .Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-09-26T21:14:28.637Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber("acquirer_reference_number") + .retrievalReferenceNumber("retrieval_reference_number") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard + .builder() + .banknetReferenceNumber("banknet_reference_number") + .originalBanknetReferenceNumber( + "original_banknet_reference_number" + ) + .originalSwitchSerialNumber( + "original_switch_serial_number" + ) + .switchSerialNumber("switch_serial_number") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult + .APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.CLEARING) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .family( + AccountActivityRetrieveTransactionResponse.CardTransaction + .TransactionFamilyTypes + .CARD + ) + .build() + ) + + val roundtrippedAccountActivityRetrieveTransactionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityRetrieveTransactionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityRetrieveTransactionResponse) + .isEqualTo(accountActivityRetrieveTransactionResponse) + } + + @Test + fun ofPaymentTransaction() { + val paymentTransaction = + AccountActivityRetrieveTransactionResponse.PaymentTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .TransactionCategory + .ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .descriptor("descriptor") + .direction( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.Direction.CREDIT + ) + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .TransactionFamilyTypes + .CARD + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .method( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.Method + .ACH_NEXT_DAY + ) + .methodAttributes( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.MethodAttributes + .AchMethodAttributes + .builder() + .secCode( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .MethodAttributes + .AchMethodAttributes + .SecCode + .CCD + ) + .addenda("addenda") + .companyId("company_id") + .receiptRoutingNumber("receipt_routing_number") + .retries(0L) + .returnReasonCode("return_reason_code") + .addTraceNumber("string") + .build() + ) + .pendingAmount(200L) + .relatedAccountTokens( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .RelatedAccountTokens + .builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.TransactionResult + .APPROVED + ) + .settledAmount(500L) + .source(AccountActivityRetrieveTransactionResponse.PaymentTransaction.Source.LITHIC) + .status( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userDefinedId("user_defined_id") + .build() + + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofPaymentTransaction(paymentTransaction) + + assertThat(accountActivityRetrieveTransactionResponse.financialTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.cardTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.paymentTransaction()) + .contains(paymentTransaction) + assertThat(accountActivityRetrieveTransactionResponse.externalPayment()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.managementOperationTransaction()) + .isEmpty + } + + @Test + fun ofPaymentTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofPaymentTransaction( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .TransactionCategory + .ACH + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .descriptor("descriptor") + .direction( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.Direction + .CREDIT + ) + .addEvent(JsonValue.from(mapOf())) + .family( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .TransactionFamilyTypes + .CARD + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .method( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.Method + .ACH_NEXT_DAY + ) + .methodAttributes( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .MethodAttributes + .AchMethodAttributes + .builder() + .secCode( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .MethodAttributes + .AchMethodAttributes + .SecCode + .CCD + ) + .addenda("addenda") + .companyId("company_id") + .receiptRoutingNumber("receipt_routing_number") + .retries(0L) + .returnReasonCode("return_reason_code") + .addTraceNumber("string") + .build() + ) + .pendingAmount(200L) + .relatedAccountTokens( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .RelatedAccountTokens + .builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .TransactionResult + .APPROVED + ) + .settledAmount(500L) + .source( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.Source.LITHIC + ) + .status( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .TransactionStatus + .PENDING + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userDefinedId("user_defined_id") + .build() + ) + + val roundtrippedAccountActivityRetrieveTransactionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityRetrieveTransactionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityRetrieveTransactionResponse) + .isEqualTo(accountActivityRetrieveTransactionResponse) + } + + @Test + fun ofExternalPayment() { + val externalPayment = + ExternalPayment.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ExternalPayment.TransactionFamilyTypes.CARD) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .build() + + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofExternalPayment(externalPayment) + + assertThat(accountActivityRetrieveTransactionResponse.financialTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.cardTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.paymentTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.externalPayment()) + .contains(externalPayment) + assertThat(accountActivityRetrieveTransactionResponse.managementOperationTransaction()) + .isEmpty + } + + @Test + fun ofExternalPaymentRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofExternalPayment( + ExternalPayment.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ExternalPayment.TransactionFamilyTypes.CARD) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .build() + ) + + val roundtrippedAccountActivityRetrieveTransactionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityRetrieveTransactionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityRetrieveTransactionResponse) + .isEqualTo(accountActivityRetrieveTransactionResponse) + } + + @Test + fun ofManagementOperationTransaction() { + val managementOperationTransaction = + ManagementOperationTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ManagementOperationTransaction.TransactionFamilyTypes.CARD) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .build() + + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofManagementOperationTransaction( + managementOperationTransaction + ) + + assertThat(accountActivityRetrieveTransactionResponse.financialTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.bookTransferTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.cardTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.paymentTransaction()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.externalPayment()).isEmpty + assertThat(accountActivityRetrieveTransactionResponse.managementOperationTransaction()) + .contains(managementOperationTransaction) + } + + @Test + fun ofManagementOperationTransactionRoundtrip() { + val jsonMapper = jsonMapper() + val accountActivityRetrieveTransactionResponse = + AccountActivityRetrieveTransactionResponse.ofManagementOperationTransaction( + ManagementOperationTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .family(ManagementOperationTransaction.TransactionFamilyTypes.CARD) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category( + ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE + ) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent + .DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .build() + ) + + val roundtrippedAccountActivityRetrieveTransactionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountActivityRetrieveTransactionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountActivityRetrieveTransactionResponse) + .isEqualTo(accountActivityRetrieveTransactionResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val accountActivityRetrieveTransactionResponse = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + accountActivityRetrieveTransactionResponse.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferListPageResponseTest.kt index 14797dd73..1d4d12296 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferListPageResponseTest.kt @@ -35,12 +35,28 @@ internal class BookTransferListPageResponseTest { .type("type") .build() ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .result(BookTransferResponse.Result.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) .toFinancialAccountToken(JsonValue.from(mapOf())) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken( + "123e4567-e89b-12d3-a456-426614174000" + ) + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -68,12 +84,26 @@ internal class BookTransferListPageResponseTest { .type("type") .build() ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .result(BookTransferResponse.Result.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) .toFinancialAccountToken(JsonValue.from(mapOf())) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -105,12 +135,28 @@ internal class BookTransferListPageResponseTest { .type("type") .build() ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .result(BookTransferResponse.Result.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) .toFinancialAccountToken(JsonValue.from(mapOf())) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken( + "123e4567-e89b-12d3-a456-426614174000" + ) + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferResponseTest.kt index c9bc1484f..c271e6c35 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferResponseTest.kt @@ -33,12 +33,26 @@ internal class BookTransferResponseTest { .type("type") .build() ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .result(BookTransferResponse.Result.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) .toFinancialAccountToken(JsonValue.from(mapOf())) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -63,6 +77,14 @@ internal class BookTransferResponseTest { .type("type") .build() ) + assertThat(bookTransferResponse.externalResource()) + .contains( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) assertThat(bookTransferResponse.fromFinancialAccountToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(bookTransferResponse.pendingAmount()).isEqualTo(0L) @@ -71,6 +93,14 @@ internal class BookTransferResponseTest { assertThat(bookTransferResponse.status()).isEqualTo(BookTransferResponse.Status.DECLINED) assertThat(bookTransferResponse._toFinancialAccountToken()) .isEqualTo(JsonValue.from(mapOf())) + assertThat(bookTransferResponse.transactionSeries()) + .contains( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) assertThat(bookTransferResponse.updated()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } @@ -98,12 +128,26 @@ internal class BookTransferResponseTest { .type("type") .build() ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .result(BookTransferResponse.Result.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) .toFinancialAccountToken(JsonValue.from(mapOf())) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt index b657da8b3..f7adb8d42 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt @@ -46,6 +46,12 @@ internal class PaymentCreateResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) @@ -105,6 +111,13 @@ internal class PaymentCreateResponseTest { .build() ) assertThat(paymentCreateResponse.pendingAmount()).isEqualTo(0L) + assertThat(paymentCreateResponse.relatedAccountTokens()) + .isEqualTo( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) assertThat(paymentCreateResponse.result()).isEqualTo(Payment.Result.APPROVED) assertThat(paymentCreateResponse.settledAmount()).isEqualTo(0L) assertThat(paymentCreateResponse.source()).isEqualTo(Payment.Source.CUSTOMER) @@ -167,6 +180,12 @@ internal class PaymentCreateResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt index 8868e861b..b2d38f636 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt @@ -50,6 +50,12 @@ internal class PaymentListPageResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) @@ -96,6 +102,12 @@ internal class PaymentListPageResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) @@ -148,6 +160,12 @@ internal class PaymentListPageResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt index 028ee3c21..14f4cfb19 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt @@ -46,6 +46,12 @@ internal class PaymentRetryResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) @@ -105,6 +111,13 @@ internal class PaymentRetryResponseTest { .build() ) assertThat(paymentRetryResponse.pendingAmount()).isEqualTo(0L) + assertThat(paymentRetryResponse.relatedAccountTokens()) + .isEqualTo( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) assertThat(paymentRetryResponse.result()).isEqualTo(Payment.Result.APPROVED) assertThat(paymentRetryResponse.settledAmount()).isEqualTo(0L) assertThat(paymentRetryResponse.source()).isEqualTo(Payment.Source.CUSTOMER) @@ -167,6 +180,12 @@ internal class PaymentRetryResponseTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt index fe6b2f910..e7be3586a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt @@ -46,6 +46,12 @@ internal class PaymentTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) @@ -90,6 +96,13 @@ internal class PaymentTest { .build() ) assertThat(payment.pendingAmount()).isEqualTo(0L) + assertThat(payment.relatedAccountTokens()) + .isEqualTo( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) assertThat(payment.result()).isEqualTo(Payment.Result.APPROVED) assertThat(payment.settledAmount()).isEqualTo(0L) assertThat(payment.source()).isEqualTo(Payment.Source.CUSTOMER) @@ -135,6 +148,12 @@ internal class PaymentTest { .build() ) .pendingAmount(0L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) .result(Payment.Result.APPROVED) .settledAmount(0L) .source(Payment.Source.CUSTOMER) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountActivityServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountActivityServiceAsyncTest.kt new file mode 100644 index 000000000..0b4e3d2eb --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountActivityServiceAsyncTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClientAsync +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AccountActivityServiceAsyncTest { + + @Test + fun list() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val accountActivityServiceAsync = client.accountActivity() + + val pageFuture = accountActivityServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun retrieveTransaction() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val accountActivityServiceAsync = client.accountActivity() + + val responseFuture = + accountActivityServiceAsync.retrieveTransaction("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val response = responseFuture.get() + response.validate() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountActivityServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountActivityServiceTest.kt new file mode 100644 index 000000000..5a036e72f --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountActivityServiceTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AccountActivityServiceTest { + + @Test + fun list() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val accountActivityService = client.accountActivity() + + val page = accountActivityService.list() + + page.response().validate() + } + + @Test + fun retrieveTransaction() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val accountActivityService = client.accountActivity() + + val response = + accountActivityService.retrieveTransaction("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + response.validate() + } +} diff --git a/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt b/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt index fed75087f..dbe22f02b 100644 --- a/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt +++ b/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt @@ -80,6 +80,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.fundingEvents()).isNotNull() assertThat(client.fraud()).isNotNull() assertThat(client.networkPrograms()).isNotNull() + assertThat(client.accountActivity()).isNotNull() } @Test