diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe3ba3317..c6e0ed7db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,31 @@ jobs: - name: Run lints run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/lithic-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build SDK + run: ./scripts/build + test: timeout-minutes: 15 name: test diff --git a/.gitignore b/.gitignore index 4e81838d6..b1346e6d1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ .gradle .idea .kotlin -build +build/ codegen.log kls_database.db diff --git a/.release-please-manifest.json b/.release-please-manifest.json index aebbc8bc4..f70d9978a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.101.0" + ".": "0.102.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 6ac2b12f6..1297b8759 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 169 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-aca56b6e4da5b97e586e66392dd3cf433208cb964e25081a661dd41cf456a88a.yml -openapi_spec_hash: 297b9f330d31db8e5832463a0ce455ba -config_hash: 99dad20b4a7d4a1390670762b9da4231 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-e16df7d65a6ababc8e0ca1f2a65070893d82d3b2b046394ab708d56fe717b3ad.yml +openapi_spec_hash: ee82cf8fd5bb6b86abbae304f6c43934 +config_hash: c6d56596249e319c59d49d8e49a190b1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3960a3f85..baabb56d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.102.0 (2025-08-18) + +Full Changelog: [v0.101.0...v0.102.0](https://github.com/lithic-com/lithic-java/compare/v0.101.0...v0.102.0) + +### Features + +* **api:** adds Event types for additional API resources ([520922c](https://github.com/lithic-com/lithic-java/commit/520922c0da2d2813f35cefdbb9c70622a0bd3794)) + + +### Performance Improvements + +* **internal:** make formatting faster ([b9b6f21](https://github.com/lithic-com/lithic-java/commit/b9b6f21cda84140211bc62b8b61edf1c7ffa31bd)) + + +### Chores + +* **ci:** add build job ([a974607](https://github.com/lithic-com/lithic-java/commit/a974607e87bfdf5d0fc756970a746f45fac7641c)) + ## 0.101.0 (2025-08-13) Full Changelog: [v0.100.0...v0.101.0](https://github.com/lithic-com/lithic-java/compare/v0.100.0...v0.101.0) diff --git a/README.md b/README.md index 0ce60d56f..0af7bfeba 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.101.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.101.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.101.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.102.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.102.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.102.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.101.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.102.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.101.0") +implementation("com.lithic.api:lithic-java:0.102.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.101.0") com.lithic.api lithic-java - 0.101.0 + 0.102.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index e59ffab12..80c9c68c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,20 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.101.0" // x-release-please-version + version = "0.102.0" // x-release-please-version +} + +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } + apply(plugin = "org.jetbrains.dokka") } subprojects { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 778c89de5..c6dc92ec5 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,7 +10,6 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/lithic.java.gradle.kts b/buildSrc/src/main/kotlin/lithic.java.gradle.kts index dfbacb86e..70fc33f41 100644 --- a/buildSrc/src/main/kotlin/lithic.java.gradle.kts +++ b/buildSrc/src/main/kotlin/lithic.java.gradle.kts @@ -1,24 +1,13 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat plugins { `java-library` - id("com.diffplug.spotless") } repositories { mavenCentral() } -configure { - java { - importOrder() - removeUnusedImports() - palantirJavaFormat() - toggleOffOn() - } -} - java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -53,3 +42,86 @@ tasks.withType().configureEach { exceptionFormat = TestExceptionFormat.FULL } } + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/lithic.kotlin.gradle.kts b/buildSrc/src/main/kotlin/lithic.kotlin.gradle.kts index 6e0bcd005..911f27dd7 100644 --- a/buildSrc/src/main/kotlin/lithic.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/lithic.kotlin.gradle.kts @@ -1,4 +1,3 @@ -import com.diffplug.gradle.spotless.SpotlessExtension import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -7,6 +6,10 @@ plugins { kotlin("jvm") } +repositories { + mavenCentral() +} + kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(21)) @@ -27,14 +30,77 @@ kotlin { } } -configure { - kotlin { - ktfmt().kotlinlangStyle() - toggleOffOn() - } -} - tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") 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 index 148aed636..5bdb4b636 100644 --- 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 @@ -19,6 +19,7 @@ import kotlin.jvm.optionals.getOrNull /** Retrieve a list of transactions across all public accounts. */ class AccountActivityListParams private constructor( + private val accountToken: String?, private val begin: OffsetDateTime?, private val businessAccountToken: String?, private val category: TransactionCategory?, @@ -33,6 +34,9 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** Filter by account token */ + fun accountToken(): Optional = Optional.ofNullable(accountToken) + /** * Date string in RFC 3339 format. Only entries created after the specified time will be * included. UTC time zone. @@ -96,6 +100,7 @@ private constructor( /** A builder for [AccountActivityListParams]. */ class Builder internal constructor() { + private var accountToken: String? = null private var begin: OffsetDateTime? = null private var businessAccountToken: String? = null private var category: TransactionCategory? = null @@ -111,6 +116,7 @@ private constructor( @JvmSynthetic internal fun from(accountActivityListParams: AccountActivityListParams) = apply { + accountToken = accountActivityListParams.accountToken begin = accountActivityListParams.begin businessAccountToken = accountActivityListParams.businessAccountToken category = accountActivityListParams.category @@ -125,6 +131,12 @@ private constructor( additionalQueryParams = accountActivityListParams.additionalQueryParams.toBuilder() } + /** Filter by account token */ + fun accountToken(accountToken: String?) = apply { this.accountToken = accountToken } + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = accountToken(accountToken.getOrNull()) + /** * Date string in RFC 3339 format. Only entries created after the specified time will be * included. UTC time zone. @@ -340,6 +352,7 @@ private constructor( */ fun build(): AccountActivityListParams = AccountActivityListParams( + accountToken, begin, businessAccountToken, category, @@ -360,6 +373,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + accountToken?.let { put("account_token", it) } begin?.let { put("begin", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } businessAccountToken?.let { put("business_account_token", it) } category?.let { put("category", it.toString()) } @@ -857,6 +871,7 @@ private constructor( } return other is AccountActivityListParams && + accountToken == other.accountToken && begin == other.begin && businessAccountToken == other.businessAccountToken && category == other.category && @@ -873,6 +888,7 @@ private constructor( override fun hashCode(): Int = Objects.hash( + accountToken, begin, businessAccountToken, category, @@ -888,5 +904,5 @@ private constructor( ) 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}" + "AccountActivityListParams{accountToken=$accountToken, 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 index 22a0f655a..d9b6c8fd3 100644 --- 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 @@ -389,7 +389,7 @@ private constructor( private val created: JsonField, private val currency: JsonField, private val descriptor: JsonField, - private val events: JsonField>, + private val events: JsonField>, private val family: JsonField, private val financialAccountToken: JsonField, private val pendingAmount: JsonField, @@ -417,7 +417,7 @@ private constructor( descriptor: JsonField = JsonMissing.of(), @JsonProperty("events") @ExcludeMissing - events: JsonField> = JsonMissing.of(), + events: JsonField> = JsonMissing.of(), @JsonProperty("family") @ExcludeMissing family: JsonField = JsonMissing.of(), @@ -502,7 +502,7 @@ private constructor( * @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") + fun events(): List = events.getRequired("events") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -603,7 +603,9 @@ private constructor( * * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Returns the raw JSON value of [family]. @@ -710,7 +712,7 @@ private constructor( private var created: JsonField? = null private var currency: JsonField? = null private var descriptor: JsonField? = null - private var events: JsonField>? = null + private var events: JsonField>? = null private var family: JsonField? = null private var financialAccountToken: JsonField? = null private var pendingAmount: JsonField? = null @@ -801,25 +803,25 @@ private constructor( fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } /** List of transaction events */ - fun events(events: List) = events(JsonField.of(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. + * 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 { + fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [events]. + * Adds a single [FinancialEvent] to [events]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addEvent(event: JsonValue) = apply { + fun addEvent(event: FinancialEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) @@ -990,7 +992,7 @@ private constructor( created() currency() descriptor() - events() + events().forEach { it.validate() } family().validate() financialAccountToken() pendingAmount() @@ -1022,7 +1024,7 @@ private constructor( (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) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (family.asKnown().getOrNull()?.validity() ?: 0) + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + (if (pendingAmount.asKnown().isPresent) 1 else 0) + @@ -1232,133 +1234,262 @@ private constructor( override fun toString() = value.toString() } - class TransactionFamilyTypes - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Financial Event */ + class FinancialEvent + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val result: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this(token, amount, created, result, type, mutableMapOf()) /** - * Returns this class instance's raw value. + * Globally unique identifier. * - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @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") + fun token(): Optional = token.getOptional("token") - @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + /** + * Amount of the financial event that has been settled in the currency's smallest unit + * (e.g., cents). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + /** + * Date and time when the financial event occurred. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") - @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) - } + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") - /** An enum containing [TransactionFamilyTypes]'s known values. */ - enum class Known { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, - } + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") /** - * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] - * member. + * Returns the raw JSON value of [token]. * - * 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. + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. */ - enum class Value { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, - /** - * An enum member indicating that [TransactionFamilyTypes] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Returns the raw JSON value of [amount]. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - 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 - } + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * 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. + * Returns the raw JSON value of [created]. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - 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") - } + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [result]. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * 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 [type]. * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") + @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 [FinancialEvent]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FinancialEvent]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var amount: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(financialEvent: FinancialEvent) = apply { + token = financialEvent.token + amount = financialEvent.amount + created = financialEvent.created + result = financialEvent.result + type = financialEvent.type + additionalProperties = financialEvent.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 } + + /** + * Amount of the financial event that has been settled in the currency's smallest + * unit (e.g., cents). + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Date and time when the financial event 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 } + + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + fun result(result: Result) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] 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 } + + fun type(type: FinancialEventType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FinancialEventType] + * 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 [FinancialEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FinancialEvent = + FinancialEvent( + token, + amount, + created, + result, + type, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): TransactionFamilyTypes = apply { + fun validate(): FinancialEvent = apply { if (validated) { return@apply } - known() + token() + amount() + created() + result().ifPresent { it.validate() } + type().ifPresent { it.validate() } validated = true } @@ -1376,273 +1507,830 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + class Result @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is TransactionFamilyTypes && value == other.value - } + /** + * 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 - override fun hashCode() = value.hashCode() + companion object { - override fun toString() = value.toString() - } + @JvmField val APPROVED = of("APPROVED") - /** Transaction result */ - class TransactionResult - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val DECLINED = of("DECLINED") - /** - * 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 { + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } - @JvmField val APPROVED = of("APPROVED") + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - @JvmField val DECLINED = of("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, + } - @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) - } + /** + * 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 + } - /** An enum containing [TransactionResult]'s known values. */ - enum class Known { - APPROVED, - DECLINED, - } + /** + * 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") + } - /** - * 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. + * 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. */ - _UNKNOWN, - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - /** - * 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 - } + private var validated: Boolean = false - /** - * 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") - } + fun validate(): Result = apply { + if (validated) { + return@apply + } - /** - * 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") + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - fun validate(): TransactionResult = apply { - if (validated) { - return@apply + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && value == other.value } - known() - validated = true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + class FinancialEventType + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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 + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is TransactionResult && value == other.value - } + @JvmField val ACH_ORIGINATION_CANCELLED = of("ACH_ORIGINATION_CANCELLED") - override fun hashCode() = value.hashCode() + @JvmField val ACH_ORIGINATION_INITIATED = of("ACH_ORIGINATION_INITIATED") - override fun toString() = value.toString() - } + @JvmField val ACH_ORIGINATION_PROCESSED = of("ACH_ORIGINATION_PROCESSED") - /** The status of the transaction */ - class TransactionStatus - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val ACH_ORIGINATION_RELEASED = of("ACH_ORIGINATION_RELEASED") - /** - * 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 + @JvmField val ACH_ORIGINATION_REVIEWED = of("ACH_ORIGINATION_REVIEWED") - companion object { + @JvmField val ACH_ORIGINATION_SETTLED = of("ACH_ORIGINATION_SETTLED") - @JvmField val PENDING = of("PENDING") + @JvmField val ACH_RECEIPT_PROCESSED = of("ACH_RECEIPT_PROCESSED") - @JvmField val SETTLED = of("SETTLED") + @JvmField val ACH_RECEIPT_SETTLED = of("ACH_RECEIPT_SETTLED") - @JvmField val DECLINED = of("DECLINED") + @JvmField val ACH_RETURN_INITIATED = of("ACH_RETURN_INITIATED") - @JvmField val REVERSED = of("REVERSED") + @JvmField val ACH_RETURN_PROCESSED = of("ACH_RETURN_PROCESSED") - @JvmField val CANCELED = of("CANCELED") + @JvmField val ACH_RETURN_SETTLED = of("ACH_RETURN_SETTLED") - @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) - } + @JvmField val AUTHORIZATION = of("AUTHORIZATION") - /** An enum containing [TransactionStatus]'s known values. */ - enum class Known { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - } + @JvmField val AUTHORIZATION_ADVICE = of("AUTHORIZATION_ADVICE") - /** - * 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, - } + @JvmField val AUTHORIZATION_EXPIRY = of("AUTHORIZATION_EXPIRY") - /** - * 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 - } + @JvmField val AUTHORIZATION_REVERSAL = of("AUTHORIZATION_REVERSAL") - /** - * 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") - } + @JvmField val BALANCE_INQUIRY = of("BALANCE_INQUIRY") - /** - * 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") - } + @JvmField val BILLING_ERROR = of("BILLING_ERROR") - private var validated: Boolean = false + @JvmField val BILLING_ERROR_REVERSAL = of("BILLING_ERROR_REVERSAL") - fun validate(): TransactionStatus = apply { - if (validated) { - return@apply - } + @JvmField val CARD_TO_CARD = of("CARD_TO_CARD") + + @JvmField val CASH_BACK = of("CASH_BACK") + + @JvmField val CASH_BACK_REVERSAL = of("CASH_BACK_REVERSAL") + + @JvmField val CLEARING = of("CLEARING") + + @JvmField val COLLECTION = of("COLLECTION") + + @JvmField val CORRECTION_CREDIT = of("CORRECTION_CREDIT") + + @JvmField val CORRECTION_DEBIT = of("CORRECTION_DEBIT") + + @JvmField val CREDIT_AUTHORIZATION = of("CREDIT_AUTHORIZATION") + + @JvmField val CREDIT_AUTHORIZATION_ADVICE = of("CREDIT_AUTHORIZATION_ADVICE") + + @JvmField val CURRENCY_CONVERSION = of("CURRENCY_CONVERSION") + + @JvmField val CURRENCY_CONVERSION_REVERSAL = of("CURRENCY_CONVERSION_REVERSAL") + + @JvmField val DISPUTE_WON = of("DISPUTE_WON") + + @JvmField val EXTERNAL_ACH_CANCELED = of("EXTERNAL_ACH_CANCELED") + + @JvmField val EXTERNAL_ACH_INITIATED = of("EXTERNAL_ACH_INITIATED") + + @JvmField val EXTERNAL_ACH_RELEASED = of("EXTERNAL_ACH_RELEASED") + + @JvmField val EXTERNAL_ACH_REVERSED = of("EXTERNAL_ACH_REVERSED") + + @JvmField val EXTERNAL_ACH_SETTLED = of("EXTERNAL_ACH_SETTLED") + + @JvmField val EXTERNAL_CHECK_CANCELED = of("EXTERNAL_CHECK_CANCELED") + + @JvmField val EXTERNAL_CHECK_INITIATED = of("EXTERNAL_CHECK_INITIATED") + + @JvmField val EXTERNAL_CHECK_RELEASED = of("EXTERNAL_CHECK_RELEASED") + + @JvmField val EXTERNAL_CHECK_REVERSED = of("EXTERNAL_CHECK_REVERSED") + + @JvmField val EXTERNAL_CHECK_SETTLED = of("EXTERNAL_CHECK_SETTLED") + + @JvmField val EXTERNAL_TRANSFER_CANCELED = of("EXTERNAL_TRANSFER_CANCELED") + + @JvmField val EXTERNAL_TRANSFER_INITIATED = of("EXTERNAL_TRANSFER_INITIATED") + + @JvmField val EXTERNAL_TRANSFER_RELEASED = of("EXTERNAL_TRANSFER_RELEASED") + + @JvmField val EXTERNAL_TRANSFER_REVERSED = of("EXTERNAL_TRANSFER_REVERSED") + + @JvmField val EXTERNAL_TRANSFER_SETTLED = of("EXTERNAL_TRANSFER_SETTLED") + + @JvmField val EXTERNAL_WIRE_CANCELED = of("EXTERNAL_WIRE_CANCELED") + + @JvmField val EXTERNAL_WIRE_INITIATED = of("EXTERNAL_WIRE_INITIATED") + + @JvmField val EXTERNAL_WIRE_RELEASED = of("EXTERNAL_WIRE_RELEASED") + + @JvmField val EXTERNAL_WIRE_REVERSED = of("EXTERNAL_WIRE_REVERSED") + + @JvmField val EXTERNAL_WIRE_SETTLED = of("EXTERNAL_WIRE_SETTLED") + + @JvmField val FINANCIAL_AUTHORIZATION = of("FINANCIAL_AUTHORIZATION") + + @JvmField + val FINANCIAL_CREDIT_AUTHORIZATION = of("FINANCIAL_CREDIT_AUTHORIZATION") + + @JvmField val INTEREST = of("INTEREST") + + @JvmField val INTEREST_REVERSAL = of("INTEREST_REVERSAL") + + @JvmField val INTERNAL_ADJUSTMENT = of("INTERNAL_ADJUSTMENT") + + @JvmField val LATE_PAYMENT = of("LATE_PAYMENT") + + @JvmField val LATE_PAYMENT_REVERSAL = of("LATE_PAYMENT_REVERSAL") + + @JvmField val LOSS_WRITE_OFF = of("LOSS_WRITE_OFF") + + @JvmField val PROVISIONAL_CREDIT = of("PROVISIONAL_CREDIT") + + @JvmField val PROVISIONAL_CREDIT_REVERSAL = of("PROVISIONAL_CREDIT_REVERSAL") + + @JvmField val SERVICE = of("SERVICE") + + @JvmField val RETURN = of("RETURN") + + @JvmField val RETURN_REVERSAL = of("RETURN_REVERSAL") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val TRANSFER_INSUFFICIENT_FUNDS = of("TRANSFER_INSUFFICIENT_FUNDS") + + @JvmField val RETURNED_PAYMENT = of("RETURNED_PAYMENT") + + @JvmField val RETURNED_PAYMENT_REVERSAL = of("RETURNED_PAYMENT_REVERSAL") + + @JvmField val LITHIC_NETWORK_PAYMENT = of("LITHIC_NETWORK_PAYMENT") + + @JvmStatic fun of(value: String) = FinancialEventType(JsonField.of(value)) + } + + /** An enum containing [FinancialEventType]'s known values. */ + enum class Known { + ACH_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_ORIGINATION_SETTLED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, + AUTHORIZATION, + AUTHORIZATION_ADVICE, + AUTHORIZATION_EXPIRY, + AUTHORIZATION_REVERSAL, + BALANCE_INQUIRY, + BILLING_ERROR, + BILLING_ERROR_REVERSAL, + CARD_TO_CARD, + CASH_BACK, + CASH_BACK_REVERSAL, + CLEARING, + COLLECTION, + CORRECTION_CREDIT, + CORRECTION_DEBIT, + CREDIT_AUTHORIZATION, + CREDIT_AUTHORIZATION_ADVICE, + CURRENCY_CONVERSION, + CURRENCY_CONVERSION_REVERSAL, + DISPUTE_WON, + EXTERNAL_ACH_CANCELED, + EXTERNAL_ACH_INITIATED, + EXTERNAL_ACH_RELEASED, + EXTERNAL_ACH_REVERSED, + EXTERNAL_ACH_SETTLED, + EXTERNAL_CHECK_CANCELED, + EXTERNAL_CHECK_INITIATED, + EXTERNAL_CHECK_RELEASED, + EXTERNAL_CHECK_REVERSED, + EXTERNAL_CHECK_SETTLED, + EXTERNAL_TRANSFER_CANCELED, + EXTERNAL_TRANSFER_INITIATED, + EXTERNAL_TRANSFER_RELEASED, + EXTERNAL_TRANSFER_REVERSED, + EXTERNAL_TRANSFER_SETTLED, + EXTERNAL_WIRE_CANCELED, + EXTERNAL_WIRE_INITIATED, + EXTERNAL_WIRE_RELEASED, + EXTERNAL_WIRE_REVERSED, + EXTERNAL_WIRE_SETTLED, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + INTEREST, + INTEREST_REVERSAL, + INTERNAL_ADJUSTMENT, + LATE_PAYMENT, + LATE_PAYMENT_REVERSAL, + LOSS_WRITE_OFF, + PROVISIONAL_CREDIT, + PROVISIONAL_CREDIT_REVERSAL, + SERVICE, + RETURN, + RETURN_REVERSAL, + TRANSFER, + TRANSFER_INSUFFICIENT_FUNDS, + RETURNED_PAYMENT, + RETURNED_PAYMENT_REVERSAL, + LITHIC_NETWORK_PAYMENT, + } + + /** + * An enum containing [FinancialEventType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [FinancialEventType] 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_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_ORIGINATION_SETTLED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, + AUTHORIZATION, + AUTHORIZATION_ADVICE, + AUTHORIZATION_EXPIRY, + AUTHORIZATION_REVERSAL, + BALANCE_INQUIRY, + BILLING_ERROR, + BILLING_ERROR_REVERSAL, + CARD_TO_CARD, + CASH_BACK, + CASH_BACK_REVERSAL, + CLEARING, + COLLECTION, + CORRECTION_CREDIT, + CORRECTION_DEBIT, + CREDIT_AUTHORIZATION, + CREDIT_AUTHORIZATION_ADVICE, + CURRENCY_CONVERSION, + CURRENCY_CONVERSION_REVERSAL, + DISPUTE_WON, + EXTERNAL_ACH_CANCELED, + EXTERNAL_ACH_INITIATED, + EXTERNAL_ACH_RELEASED, + EXTERNAL_ACH_REVERSED, + EXTERNAL_ACH_SETTLED, + EXTERNAL_CHECK_CANCELED, + EXTERNAL_CHECK_INITIATED, + EXTERNAL_CHECK_RELEASED, + EXTERNAL_CHECK_REVERSED, + EXTERNAL_CHECK_SETTLED, + EXTERNAL_TRANSFER_CANCELED, + EXTERNAL_TRANSFER_INITIATED, + EXTERNAL_TRANSFER_RELEASED, + EXTERNAL_TRANSFER_REVERSED, + EXTERNAL_TRANSFER_SETTLED, + EXTERNAL_WIRE_CANCELED, + EXTERNAL_WIRE_INITIATED, + EXTERNAL_WIRE_RELEASED, + EXTERNAL_WIRE_REVERSED, + EXTERNAL_WIRE_SETTLED, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + INTEREST, + INTEREST_REVERSAL, + INTERNAL_ADJUSTMENT, + LATE_PAYMENT, + LATE_PAYMENT_REVERSAL, + LOSS_WRITE_OFF, + PROVISIONAL_CREDIT, + PROVISIONAL_CREDIT_REVERSAL, + SERVICE, + RETURN, + RETURN_REVERSAL, + TRANSFER, + TRANSFER_INSUFFICIENT_FUNDS, + RETURNED_PAYMENT, + RETURNED_PAYMENT_REVERSAL, + LITHIC_NETWORK_PAYMENT, + /** + * An enum member indicating that [FinancialEventType] 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_ORIGINATION_CANCELLED -> Value.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Value.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Value.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_RELEASED -> Value.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Value.ACH_ORIGINATION_REVIEWED + ACH_ORIGINATION_SETTLED -> Value.ACH_ORIGINATION_SETTLED + ACH_RECEIPT_PROCESSED -> Value.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Value.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Value.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Value.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Value.ACH_RETURN_SETTLED + AUTHORIZATION -> Value.AUTHORIZATION + AUTHORIZATION_ADVICE -> Value.AUTHORIZATION_ADVICE + AUTHORIZATION_EXPIRY -> Value.AUTHORIZATION_EXPIRY + AUTHORIZATION_REVERSAL -> Value.AUTHORIZATION_REVERSAL + BALANCE_INQUIRY -> Value.BALANCE_INQUIRY + BILLING_ERROR -> Value.BILLING_ERROR + BILLING_ERROR_REVERSAL -> Value.BILLING_ERROR_REVERSAL + CARD_TO_CARD -> Value.CARD_TO_CARD + CASH_BACK -> Value.CASH_BACK + CASH_BACK_REVERSAL -> Value.CASH_BACK_REVERSAL + CLEARING -> Value.CLEARING + COLLECTION -> Value.COLLECTION + CORRECTION_CREDIT -> Value.CORRECTION_CREDIT + CORRECTION_DEBIT -> Value.CORRECTION_DEBIT + CREDIT_AUTHORIZATION -> Value.CREDIT_AUTHORIZATION + CREDIT_AUTHORIZATION_ADVICE -> Value.CREDIT_AUTHORIZATION_ADVICE + CURRENCY_CONVERSION -> Value.CURRENCY_CONVERSION + CURRENCY_CONVERSION_REVERSAL -> Value.CURRENCY_CONVERSION_REVERSAL + DISPUTE_WON -> Value.DISPUTE_WON + EXTERNAL_ACH_CANCELED -> Value.EXTERNAL_ACH_CANCELED + EXTERNAL_ACH_INITIATED -> Value.EXTERNAL_ACH_INITIATED + EXTERNAL_ACH_RELEASED -> Value.EXTERNAL_ACH_RELEASED + EXTERNAL_ACH_REVERSED -> Value.EXTERNAL_ACH_REVERSED + EXTERNAL_ACH_SETTLED -> Value.EXTERNAL_ACH_SETTLED + EXTERNAL_CHECK_CANCELED -> Value.EXTERNAL_CHECK_CANCELED + EXTERNAL_CHECK_INITIATED -> Value.EXTERNAL_CHECK_INITIATED + EXTERNAL_CHECK_RELEASED -> Value.EXTERNAL_CHECK_RELEASED + EXTERNAL_CHECK_REVERSED -> Value.EXTERNAL_CHECK_REVERSED + EXTERNAL_CHECK_SETTLED -> Value.EXTERNAL_CHECK_SETTLED + EXTERNAL_TRANSFER_CANCELED -> Value.EXTERNAL_TRANSFER_CANCELED + EXTERNAL_TRANSFER_INITIATED -> Value.EXTERNAL_TRANSFER_INITIATED + EXTERNAL_TRANSFER_RELEASED -> Value.EXTERNAL_TRANSFER_RELEASED + EXTERNAL_TRANSFER_REVERSED -> Value.EXTERNAL_TRANSFER_REVERSED + EXTERNAL_TRANSFER_SETTLED -> Value.EXTERNAL_TRANSFER_SETTLED + EXTERNAL_WIRE_CANCELED -> Value.EXTERNAL_WIRE_CANCELED + EXTERNAL_WIRE_INITIATED -> Value.EXTERNAL_WIRE_INITIATED + EXTERNAL_WIRE_RELEASED -> Value.EXTERNAL_WIRE_RELEASED + EXTERNAL_WIRE_REVERSED -> Value.EXTERNAL_WIRE_REVERSED + EXTERNAL_WIRE_SETTLED -> Value.EXTERNAL_WIRE_SETTLED + FINANCIAL_AUTHORIZATION -> Value.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Value.FINANCIAL_CREDIT_AUTHORIZATION + INTEREST -> Value.INTEREST + INTEREST_REVERSAL -> Value.INTEREST_REVERSAL + INTERNAL_ADJUSTMENT -> Value.INTERNAL_ADJUSTMENT + LATE_PAYMENT -> Value.LATE_PAYMENT + LATE_PAYMENT_REVERSAL -> Value.LATE_PAYMENT_REVERSAL + LOSS_WRITE_OFF -> Value.LOSS_WRITE_OFF + PROVISIONAL_CREDIT -> Value.PROVISIONAL_CREDIT + PROVISIONAL_CREDIT_REVERSAL -> Value.PROVISIONAL_CREDIT_REVERSAL + SERVICE -> Value.SERVICE + RETURN -> Value.RETURN + RETURN_REVERSAL -> Value.RETURN_REVERSAL + TRANSFER -> Value.TRANSFER + TRANSFER_INSUFFICIENT_FUNDS -> Value.TRANSFER_INSUFFICIENT_FUNDS + RETURNED_PAYMENT -> Value.RETURNED_PAYMENT + RETURNED_PAYMENT_REVERSAL -> Value.RETURNED_PAYMENT_REVERSAL + LITHIC_NETWORK_PAYMENT -> Value.LITHIC_NETWORK_PAYMENT + 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_ORIGINATION_CANCELLED -> Known.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Known.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Known.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_RELEASED -> Known.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Known.ACH_ORIGINATION_REVIEWED + ACH_ORIGINATION_SETTLED -> Known.ACH_ORIGINATION_SETTLED + ACH_RECEIPT_PROCESSED -> Known.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Known.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Known.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Known.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Known.ACH_RETURN_SETTLED + AUTHORIZATION -> Known.AUTHORIZATION + AUTHORIZATION_ADVICE -> Known.AUTHORIZATION_ADVICE + AUTHORIZATION_EXPIRY -> Known.AUTHORIZATION_EXPIRY + AUTHORIZATION_REVERSAL -> Known.AUTHORIZATION_REVERSAL + BALANCE_INQUIRY -> Known.BALANCE_INQUIRY + BILLING_ERROR -> Known.BILLING_ERROR + BILLING_ERROR_REVERSAL -> Known.BILLING_ERROR_REVERSAL + CARD_TO_CARD -> Known.CARD_TO_CARD + CASH_BACK -> Known.CASH_BACK + CASH_BACK_REVERSAL -> Known.CASH_BACK_REVERSAL + CLEARING -> Known.CLEARING + COLLECTION -> Known.COLLECTION + CORRECTION_CREDIT -> Known.CORRECTION_CREDIT + CORRECTION_DEBIT -> Known.CORRECTION_DEBIT + CREDIT_AUTHORIZATION -> Known.CREDIT_AUTHORIZATION + CREDIT_AUTHORIZATION_ADVICE -> Known.CREDIT_AUTHORIZATION_ADVICE + CURRENCY_CONVERSION -> Known.CURRENCY_CONVERSION + CURRENCY_CONVERSION_REVERSAL -> Known.CURRENCY_CONVERSION_REVERSAL + DISPUTE_WON -> Known.DISPUTE_WON + EXTERNAL_ACH_CANCELED -> Known.EXTERNAL_ACH_CANCELED + EXTERNAL_ACH_INITIATED -> Known.EXTERNAL_ACH_INITIATED + EXTERNAL_ACH_RELEASED -> Known.EXTERNAL_ACH_RELEASED + EXTERNAL_ACH_REVERSED -> Known.EXTERNAL_ACH_REVERSED + EXTERNAL_ACH_SETTLED -> Known.EXTERNAL_ACH_SETTLED + EXTERNAL_CHECK_CANCELED -> Known.EXTERNAL_CHECK_CANCELED + EXTERNAL_CHECK_INITIATED -> Known.EXTERNAL_CHECK_INITIATED + EXTERNAL_CHECK_RELEASED -> Known.EXTERNAL_CHECK_RELEASED + EXTERNAL_CHECK_REVERSED -> Known.EXTERNAL_CHECK_REVERSED + EXTERNAL_CHECK_SETTLED -> Known.EXTERNAL_CHECK_SETTLED + EXTERNAL_TRANSFER_CANCELED -> Known.EXTERNAL_TRANSFER_CANCELED + EXTERNAL_TRANSFER_INITIATED -> Known.EXTERNAL_TRANSFER_INITIATED + EXTERNAL_TRANSFER_RELEASED -> Known.EXTERNAL_TRANSFER_RELEASED + EXTERNAL_TRANSFER_REVERSED -> Known.EXTERNAL_TRANSFER_REVERSED + EXTERNAL_TRANSFER_SETTLED -> Known.EXTERNAL_TRANSFER_SETTLED + EXTERNAL_WIRE_CANCELED -> Known.EXTERNAL_WIRE_CANCELED + EXTERNAL_WIRE_INITIATED -> Known.EXTERNAL_WIRE_INITIATED + EXTERNAL_WIRE_RELEASED -> Known.EXTERNAL_WIRE_RELEASED + EXTERNAL_WIRE_REVERSED -> Known.EXTERNAL_WIRE_REVERSED + EXTERNAL_WIRE_SETTLED -> Known.EXTERNAL_WIRE_SETTLED + FINANCIAL_AUTHORIZATION -> Known.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Known.FINANCIAL_CREDIT_AUTHORIZATION + INTEREST -> Known.INTEREST + INTEREST_REVERSAL -> Known.INTEREST_REVERSAL + INTERNAL_ADJUSTMENT -> Known.INTERNAL_ADJUSTMENT + LATE_PAYMENT -> Known.LATE_PAYMENT + LATE_PAYMENT_REVERSAL -> Known.LATE_PAYMENT_REVERSAL + LOSS_WRITE_OFF -> Known.LOSS_WRITE_OFF + PROVISIONAL_CREDIT -> Known.PROVISIONAL_CREDIT + PROVISIONAL_CREDIT_REVERSAL -> Known.PROVISIONAL_CREDIT_REVERSAL + SERVICE -> Known.SERVICE + RETURN -> Known.RETURN + RETURN_REVERSAL -> Known.RETURN_REVERSAL + TRANSFER -> Known.TRANSFER + TRANSFER_INSUFFICIENT_FUNDS -> Known.TRANSFER_INSUFFICIENT_FUNDS + RETURNED_PAYMENT -> Known.RETURNED_PAYMENT + RETURNED_PAYMENT_REVERSAL -> Known.RETURNED_PAYMENT_REVERSAL + LITHIC_NETWORK_PAYMENT -> Known.LITHIC_NETWORK_PAYMENT + else -> + throw LithicInvalidDataException("Unknown FinancialEventType: $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(): FinancialEventType = 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 other is FinancialEventType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialEvent && + token == other.token && + amount == other.amount && + created == other.created && + result == other.result && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(token, amount, created, result, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FinancialEvent{token=$token, amount=$amount, created=$created, result=$result, type=$type, additionalProperties=$additionalProperties}" + } + + 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 @@ -1669,7 +2357,7 @@ private constructor( return true } - return other is TransactionStatus && value == other.value + return other is TransactionFamilyTypes && value == other.value } override fun hashCode() = value.hashCode() @@ -1677,737 +2365,707 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Transaction result */ + class TransactionResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return 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 - } + /** + * 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 - private val hashCode: Int by lazy { - Objects.hash( - token, - category, - created, - currency, - descriptor, - events, - family, - financialAccountToken, - pendingAmount, - result, - settledAmount, - status, - updated, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val APPROVED = of("APPROVED") - 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}" - } + @JvmField val DECLINED = of("DECLINED") - /** 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, - ) { + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } - @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(), - ) + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - /** - * 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") + /** + * 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, + } - /** - * @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") + /** + * 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 + } - /** - * 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") + /** + * 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") + } - /** - * 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") + /** + * 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") + } - /** - * 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") + private var validated: Boolean = false - /** - * @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") + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } - /** - * 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") + known() + validated = true + } - /** - * 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") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** - * @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") + /** + * 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 - /** - * 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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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") + return other is TransactionResult && value == other.value + } - /** - * 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") + override fun hashCode() = value.hashCode() - /** - * 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") + override fun toString() = value.toString() + } - /** - * 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") + /** The status of the transaction */ + class TransactionStatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * 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 - /** - * @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") + companion object { - /** - * 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 + @JvmField val PENDING = of("PENDING") - /** - * 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 + @JvmField val SETTLED = of("SETTLED") - /** - * 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 + @JvmField val DECLINED = of("DECLINED") - /** - * 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 + @JvmField val REVERSED = of("REVERSED") - /** - * 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 + @JvmField val CANCELED = of("CANCELED") - /** - * 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 + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } - /** - * 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 + /** + * 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 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 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 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 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 a mutable builder for constructing an instance of [BookTransferTransaction]. + * Returns this class instance's primitive wire representation. * - * The following fields are required: - * ```java - * .token() - * .category() - * .created() - * .currency() - * .events() - * .family() - * .fromFinancialAccountToken() - * .pendingAmount() - * .result() - * .settledAmount() - * .status() - * .toFinancialAccountToken() - * .updated() - * ``` + * 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. */ - @JvmStatic fun builder() = Builder() - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - /** A builder for [BookTransferTransaction]. */ - class Builder internal constructor() { + private var validated: Boolean = false - 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() + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } - @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() + known() + validated = true } - /** Unique identifier for the transaction */ - fun token(token: String) = token(JsonField.of(token)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Sets [Builder.token] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun token(token: JsonField) = apply { this.token = token } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun category(category: TransactionCategory) = category(JsonField.of(category)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 + return other is TransactionStatus && value == other.value } - /** 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 } + override fun hashCode() = value.hashCode() - /** Currency of the transaction in ISO 4217 format */ - fun currency(currency: String) = currency(JsonField.of(currency)) + override fun toString() = value.toString() + } - /** - * 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 } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** List of events associated with this book transfer */ - fun events(events: List) = events(JsonField.of(events)) + return 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 + } - /** - * 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() } - } + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + descriptor, + events, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + status, + updated, + additionalProperties, + ) + } - /** - * 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) - } - } + override fun hashCode(): Int = hashCode - fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + 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}" + } - /** - * 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 } + /** 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, + ) { - /** Source account token */ - fun fromFinancialAccountToken(fromFinancialAccountToken: String) = - fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) + @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(), + ) - /** - * 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 - } + /** + * 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") - /** The pending amount of the transaction in cents */ - fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + /** + * @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") - /** - * 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 - } + /** + * 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") - fun result(result: TransactionResult) = result(JsonField.of(result)) + /** + * 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") - /** - * 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 } + /** + * 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") - /** The settled amount of the transaction in cents */ - fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + /** + * @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") - /** - * 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 - } + /** + * 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 status of the transaction */ - fun status(status: TransactionStatus) = status(JsonField.of(status)) + /** + * 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") - /** - * 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 } + /** + * @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") - /** Destination account token */ - fun toFinancialAccountToken(toFinancialAccountToken: String) = - toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + /** + * 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") - /** - * 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 - } + /** + * 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 */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + /** + * 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") - /** - * 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 } + /** + * 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 */ - fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + /** + * 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") - /** - * 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 + * + * @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") - /** External resource associated with the management operation */ - fun externalResource(externalResource: ExternalResource?) = - externalResource(JsonField.ofNullable(externalResource)) + /** + * @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") - /** - * Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. - */ - fun externalResource(externalResource: Optional) = - externalResource(externalResource.getOrNull()) + /** + * 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 - /** - * 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 - } + /** + * 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 - fun transactionSeries(transactionSeries: TransactionSeries?) = - transactionSeries(JsonField.ofNullable(transactionSeries)) + /** + * 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 - /** - * Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. - */ - fun transactionSeries(transactionSeries: Optional) = - transactionSeries(transactionSeries.getOrNull()) + /** + * 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 - /** - * 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 - } + /** + * 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 - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * 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 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * 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 - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * 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 - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * 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 - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * 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 an immutable instance of [BookTransferTransaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of [BookTransferTransaction]. * * The following fields are required: * ```java @@ -2425,450 +3083,409 @@ private constructor( * .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(), - ) + @JvmStatic fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): BookTransferTransaction = apply { - if (validated) { - return@apply - } + /** A builder for [BookTransferTransaction]. */ + class Builder internal constructor() { - 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 - } + 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() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false + @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() } - /** - * 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 { + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) /** - * Returns this class instance's raw value. + * Sets [Builder.token] to an arbitrary JSON 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. + * 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. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun token(token: JsonField) = apply { this.token = token } - companion object { + fun category(category: TransactionCategory) = category(JsonField.of(category)) - @JvmField val ACH = of("ACH") + /** + * 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 + } - @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) - @JvmField val CARD = of("CARD") + /** + * 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 } - @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) - @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + /** + * 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 } - @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + /** List of events associated with this book transfer */ + fun events(events: List) = events(JsonField.of(events)) - @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + /** + * 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() } + } - @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + /** + * Adds a single [BookTransferEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: BookTransferEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } - @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) - @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + /** + * 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 } - @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + /** Source account token */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) - @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + /** + * 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 + } - @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + /** The pending amount of the transaction in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) - @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + /** + * 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 } - /** 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, - } + fun result(result: TransactionResult) = result(JsonField.of(result)) /** - * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] - * member. + * Sets [Builder.result] to an arbitrary JSON value. * - * 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. + * 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. */ - 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, - } + fun result(result: JsonField) = apply { this.result = result } + + /** The settled amount of the transaction in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.settledAmount] to an arbitrary JSON 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. + * 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 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 - } + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) /** - * 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. + * Sets [Builder.status] to an arbitrary JSON value. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * 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 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") - } + fun status(status: JsonField) = apply { this.status = status } + + /** Destination account token */ + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) /** - * 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. + * Sets [Builder.toFinancialAccountToken] to an arbitrary JSON value. * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * 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 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 toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + this.toFinancialAccountToken = toFinancialAccountToken } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.updated] to an arbitrary JSON value. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TransactionCategory && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + fun updated(updated: JsonField) = apply { this.updated = updated } - class TransactionFamilyTypes - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** External identifier for the transaction */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) /** - * Returns this class instance's raw value. + * Sets [Builder.externalId] to an arbitrary JSON 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. + * 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. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } - companion object { + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) - @JvmField val CARD = of("CARD") + /** + * Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. + */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) - @JvmField val PAYMENT = of("PAYMENT") + /** + * 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 + } - @JvmField val TRANSFER = of("TRANSFER") + fun transactionSeries(transactionSeries: TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) - @JvmField val INTERNAL = of("INTERNAL") + /** + * Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. + */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) - @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + /** + * 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 + } - @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** An enum containing [TransactionFamilyTypes]'s known values. */ - enum class Known { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * 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, + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Returns an immutable instance of [BookTransferTransaction]. * - * 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. + * Further updates to this [Builder] will not mutate the returned instance. * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * ``` * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * @throws IllegalStateException if any required field is unset. */ - 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 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(), + ) + } - fun validate(): TransactionFamilyTypes = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - known() - validated = true + fun validate(): BookTransferTransaction = apply { + if (validated) { + return@apply } - 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 - } + token() + category().validate() + created() + currency() + events().forEach { it.validate() } + family().validate() + fromFinancialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + toFinancialAccountToken() + updated() + externalId() + externalResource().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + validated = true + } - return other is TransactionFamilyTypes && value == other.value + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * 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()?.sumOf { it.validity().toInt() } ?: 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 TransactionResult + class TransactionCategory @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2884,34 +3501,79 @@ private constructor( companion object { - @JvmField val APPROVED = of("APPROVED") + @JvmField val ACH = of("ACH") - @JvmField val DECLINED = of("DECLINED") + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") - @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + @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 [TransactionResult]'s known values. */ + /** An enum containing [TransactionCategory]'s known values. */ enum class Known { - APPROVED, - DECLINED, + 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 [TransactionResult]'s known values, as well as an [_UNKNOWN] + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [TransactionResult] can contain an unknown value in a couple of cases: + * 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 { - APPROVED, - DECLINED, + 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 [TransactionResult] was instantiated with an + * An enum member indicating that [TransactionCategory] was instantiated with an * unknown value. */ _UNKNOWN, @@ -2926,8 +3588,19 @@ private constructor( */ fun value(): Value = when (this) { - APPROVED -> Value.APPROVED - DECLINED -> Value.DECLINED + 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 } @@ -2942,9 +3615,20 @@ private constructor( */ fun known(): Known = when (this) { - APPROVED -> Known.APPROVED - DECLINED -> Known.DECLINED - else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + 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") } /** @@ -2963,7 +3647,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TransactionResult = apply { + fun validate(): TransactionCategory = apply { if (validated) { return@apply } @@ -2993,7 +3677,7 @@ private constructor( return true } - return other is TransactionResult && value == other.value + return other is TransactionCategory && value == other.value } override fun hashCode() = value.hashCode() @@ -3001,224 +3685,185 @@ private constructor( override fun toString() = value.toString() } - /** The status of the transaction */ - class TransactionStatus - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Book transfer Event */ + class BookTransferEvent + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val detailedResults: JsonField, + private val memo: JsonField, + private val result: JsonField, + private val subtype: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("detailed_results") + @ExcludeMissing + detailedResults: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this( + token, + amount, + created, + detailedResults, + memo, + result, + subtype, + type, + mutableMapOf(), + ) /** - * Returns this class instance's raw value. + * Globally unique identifier. * - * 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. + * @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). */ - @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") + fun token(): String = token.getRequired("token") - @JvmField val CANCELED = of("CANCELED") + /** + * Amount of the financial event that has been settled in the currency's smallest unit + * (e.g., 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 amount(): Long = amount.getRequired("amount") - @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) - } + /** + * Date and time when the financial event 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") - /** An enum containing [TransactionStatus]'s known values. */ - enum class Known { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - } + /** + * @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 detailedResults(): BookTransferDetailedResults = + detailedResults.getRequired("detailed_results") /** - * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] - * member. + * Memo for the transfer. * - * 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. + * @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). */ - enum class Value { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - /** - * An enum member indicating that [TransactionStatus] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun memo(): String = memo.getRequired("memo") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * @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 value(): Value = - when (this) { - PENDING -> Value.PENDING - SETTLED -> Value.SETTLED - DECLINED -> Value.DECLINED - REVERSED -> Value.REVERSED - CANCELED -> Value.CANCELED - else -> Value._UNKNOWN - } + fun result(): Result = result.getRequired("result") /** - * 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. + * The program specific subtype code for the specified category/type. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * @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 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") - } + fun subtype(): String = subtype.getRequired("subtype") /** - * 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. + * Type of the book transfer * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @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 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 - } + fun type(): BookTransferType = type.getRequired("type") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [token]. * - * Used for best match union deserialization. + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TransactionStatus && value == other.value - } + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - 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()) + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - fun relatedTransactionEventToken(): Optional = - relatedTransactionEventToken.getOptional("related_transaction_event_token") + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns the raw JSON value of [detailedResults]. + * + * Unlike [detailedResults], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun relatedTransactionToken(): Optional = - relatedTransactionToken.getOptional("related_transaction_token") + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField = detailedResults /** - * @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). + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. */ - fun type(): String = type.getRequired("type") + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** - * Returns the raw JSON value of [relatedTransactionEventToken]. + * Returns the raw JSON value of [result]. * - * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("related_transaction_event_token") - @ExcludeMissing - fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** - * Returns the raw JSON value of [relatedTransactionToken]. + * Returns the raw JSON value of [subtype]. * - * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("related_transaction_token") - @ExcludeMissing - fun _relatedTransactionToken(): JsonField = relatedTransactionToken + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** * 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 + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3235,87 +3880,153 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * Returns a mutable builder for constructing an instance of [BookTransferEvent]. * * The following fields are required: * ```java - * .relatedTransactionEventToken() - * .relatedTransactionToken() + * .token() + * .amount() + * .created() + * .detailedResults() + * .memo() + * .result() + * .subtype() * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TransactionSeries]. */ + /** A builder for [BookTransferEvent]. */ class Builder internal constructor() { - private var relatedTransactionEventToken: JsonField? = null - private var relatedTransactionToken: JsonField? = null - private var type: JsonField? = null + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var detailedResults: JsonField? = null + private var memo: JsonField? = null + private var result: JsonField? = null + private var subtype: 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() + internal fun from(bookTransferEvent: BookTransferEvent) = apply { + token = bookTransferEvent.token + amount = bookTransferEvent.amount + created = bookTransferEvent.created + detailedResults = bookTransferEvent.detailedResults + memo = bookTransferEvent.memo + result = bookTransferEvent.result + subtype = bookTransferEvent.subtype + type = bookTransferEvent.type + additionalProperties = bookTransferEvent.additionalProperties.toMutableMap() } - fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = - relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) /** - * Alias for calling [Builder.relatedTransactionEventToken] with - * `relatedTransactionEventToken.orElse(null)`. + * 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 relatedTransactionEventToken(relatedTransactionEventToken: Optional) = - relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) + fun token(token: JsonField) = apply { this.token = token } /** - * Sets [Builder.relatedTransactionEventToken] to an arbitrary JSON value. + * Amount of the financial event that has been settled in the currency's smallest + * unit (e.g., cents). + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] 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. + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = - apply { - this.relatedTransactionEventToken = relatedTransactionEventToken - } + fun amount(amount: JsonField) = apply { this.amount = amount } - fun relatedTransactionToken(relatedTransactionToken: String?) = - relatedTransactionToken(JsonField.ofNullable(relatedTransactionToken)) + /** Date and time when the financial event occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** - * Alias for calling [Builder.relatedTransactionToken] with - * `relatedTransactionToken.orElse(null)`. + * 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 relatedTransactionToken(relatedTransactionToken: Optional) = - relatedTransactionToken(relatedTransactionToken.getOrNull()) + fun created(created: JsonField) = apply { this.created = created } + + fun detailedResults(detailedResults: BookTransferDetailedResults) = + detailedResults(JsonField.of(detailedResults)) /** - * Sets [Builder.relatedTransactionToken] to an arbitrary JSON value. + * Sets [Builder.detailedResults] 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. + * You should usually call [Builder.detailedResults] with a well-typed + * [BookTransferDetailedResults] 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 detailedResults(detailedResults: JsonField) = + apply { + this.detailedResults = detailedResults + } - fun type(type: String) = type(JsonField.of(type)) + /** Memo for the transfer. */ + fun memo(memo: String) = memo(JsonField.of(memo)) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets [Builder.memo] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [String] value instead. + * You should usually call [Builder.memo] 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 memo(memo: JsonField) = apply { this.memo = memo } + + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + fun result(result: Result) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] 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 program specific subtype code for the specified category/type. */ + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) + + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + + /** Type of the book transfer */ + fun type(type: BookTransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BookTransferType] 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() @@ -3340,23 +4051,33 @@ private constructor( } /** - * Returns an immutable instance of [TransactionSeries]. + * Returns an immutable instance of [BookTransferEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .relatedTransactionEventToken() - * .relatedTransactionToken() + * .token() + * .amount() + * .created() + * .detailedResults() + * .memo() + * .result() + * .subtype() * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TransactionSeries = - TransactionSeries( - checkRequired("relatedTransactionEventToken", relatedTransactionEventToken), - checkRequired("relatedTransactionToken", relatedTransactionToken), + fun build(): BookTransferEvent = + BookTransferEvent( + checkRequired("token", token), + checkRequired("amount", amount), + checkRequired("created", created), + checkRequired("detailedResults", detailedResults), + checkRequired("memo", memo), + checkRequired("result", result), + checkRequired("subtype", subtype), checkRequired("type", type), additionalProperties.toMutableMap(), ) @@ -3364,14 +4085,19 @@ private constructor( private var validated: Boolean = false - fun validate(): TransactionSeries = apply { + fun validate(): BookTransferEvent = apply { if (validated) { return@apply } - relatedTransactionEventToken() - relatedTransactionToken() - type() + token() + amount() + created() + detailedResults().validate() + memo() + result().validate() + subtype() + type().validate() validated = true } @@ -3391,1759 +4117,1309 @@ private constructor( */ @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) + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (detailedResults.asKnown().getOrNull()?.validity() ?: 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtype.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class BookTransferDetailedResults + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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 FUNDS_INSUFFICIENT = of("FUNDS_INSUFFICIENT") + + @JvmStatic + fun of(value: String) = BookTransferDetailedResults(JsonField.of(value)) } - return other is TransactionSeries && - relatedTransactionEventToken == other.relatedTransactionEventToken && - relatedTransactionToken == other.relatedTransactionToken && - type == other.type && - additionalProperties == other.additionalProperties - } + /** An enum containing [BookTransferDetailedResults]'s known values. */ + enum class Known { + APPROVED, + FUNDS_INSUFFICIENT, + } - private val hashCode: Int by lazy { - Objects.hash( - relatedTransactionEventToken, - relatedTransactionToken, - type, - additionalProperties, - ) - } + /** + * An enum containing [BookTransferDetailedResults]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BookTransferDetailedResults] 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, + FUNDS_INSUFFICIENT, + /** + * An enum member indicating that [BookTransferDetailedResults] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } - override fun hashCode(): Int = hashCode + /** + * 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 + FUNDS_INSUFFICIENT -> Value.FUNDS_INSUFFICIENT + else -> Value._UNKNOWN + } - override fun toString() = - "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" - } + /** + * 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 + FUNDS_INSUFFICIENT -> Known.FUNDS_INSUFFICIENT + else -> + throw LithicInvalidDataException( + "Unknown BookTransferDetailedResults: $value" + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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(): BookTransferDetailedResults = 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 other is BookTransferDetailedResults && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - return 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 - } + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + class Result @JsonCreator private constructor(private val value: JsonField) : + Enum { - 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, - ) - } + /** + * 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 - override fun hashCode(): Int = hashCode + companion object { - 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}" - } + @JvmField val APPROVED = of("APPROVED") - /** 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, - ) { + @JvmField val DECLINED = of("DECLINED") - @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(), - ) + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } - 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() + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - /** - * 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") + /** + * 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, + } - /** - * 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") + /** + * 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 + } - /** - * 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") + /** + * 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") + } - /** - * 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") + /** + * 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") + } - /** - * 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") + private var validated: Boolean = false - /** - * @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") + fun validate(): Result = apply { + if (validated) { + return@apply + } - /** - * 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") + known() + validated = true + } - /** - * 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") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** - * @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") + /** + * 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 - /** - * 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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @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") + return other is Result && value == other.value + } - /** - * 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") + override fun hashCode() = value.hashCode() - /** - * @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") + override fun toString() = value.toString() + } - /** - * 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") + /** Type of the book transfer */ + class BookTransferType + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * 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 - /** - * 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") + companion object { - /** - * 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") + @JvmField val ATM_WITHDRAWAL = of("ATM_WITHDRAWAL") - /** - * 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") + @JvmField val ATM_DECLINE = of("ATM_DECLINE") - /** - * @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") + @JvmField val INTERNATIONAL_ATM_WITHDRAWAL = of("INTERNATIONAL_ATM_WITHDRAWAL") - /** - * @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") + @JvmField val INACTIVITY = of("INACTIVITY") - /** - * 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") + @JvmField val STATEMENT = of("STATEMENT") - /** - * 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") + @JvmField val MONTHLY = of("MONTHLY") - /** - * @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") + @JvmField val QUARTERLY = of("QUARTERLY") - /** - * 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") + @JvmField val ANNUAL = of("ANNUAL") - /** - * @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") + @JvmField val CUSTOMER_SERVICE = of("CUSTOMER_SERVICE") - /** - * @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") + @JvmField val ACCOUNT_MAINTENANCE = of("ACCOUNT_MAINTENANCE") - /** - * 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 + @JvmField val ACCOUNT_ACTIVATION = of("ACCOUNT_ACTIVATION") - /** - * 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 + @JvmField val ACCOUNT_CLOSURE = of("ACCOUNT_CLOSURE") - /** - * 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 + @JvmField val CARD_REPLACEMENT = of("CARD_REPLACEMENT") - /** - * 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 + @JvmField val CARD_DELIVERY = of("CARD_DELIVERY") - /** - * 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 + @JvmField val CARD_CREATE = of("CARD_CREATE") - /** - * 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 + @JvmField val CURRENCY_CONVERSION = of("CURRENCY_CONVERSION") - /** - * 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 + @JvmField val INTEREST = of("INTEREST") - /** - * 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 + @JvmField val LATE_PAYMENT = of("LATE_PAYMENT") - /** - * 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 + @JvmField val BILL_PAYMENT = of("BILL_PAYMENT") - /** - * 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 + @JvmField val CASH_BACK = of("CASH_BACK") - /** - * 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 + @JvmField val ACCOUNT_TO_ACCOUNT = of("ACCOUNT_TO_ACCOUNT") - /** - * 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 + @JvmField val CARD_TO_CARD = of("CARD_TO_CARD") - /** - * 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 + @JvmField val DISBURSE = of("DISBURSE") - /** - * 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 + @JvmField val BILLING_ERROR = of("BILLING_ERROR") - /** - * 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 + @JvmField val LOSS_WRITE_OFF = of("LOSS_WRITE_OFF") - /** - * 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 + @JvmField val EXPIRED_CARD = of("EXPIRED_CARD") - /** - * 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 + @JvmField val EARLY_DERECOGNITION = of("EARLY_DERECOGNITION") - /** - * 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 + @JvmField val ESCHEATMENT = of("ESCHEATMENT") - /** - * 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 + @JvmField val INACTIVITY_FEE_DOWN = of("INACTIVITY_FEE_DOWN") - /** - * 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 + @JvmField val PROVISIONAL_CREDIT = of("PROVISIONAL_CREDIT") - /** - * 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 + @JvmField val DISPUTE_WON = of("DISPUTE_WON") - /** - * 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 + @JvmField val SERVICE = of("SERVICE") - /** - * 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 + @JvmField val TRANSFER = of("TRANSFER") - /** - * 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 + @JvmStatic fun of(value: String) = BookTransferType(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [BookTransferType]'s known values. */ + enum class Known { + ATM_WITHDRAWAL, + ATM_DECLINE, + INTERNATIONAL_ATM_WITHDRAWAL, + INACTIVITY, + STATEMENT, + MONTHLY, + QUARTERLY, + ANNUAL, + CUSTOMER_SERVICE, + ACCOUNT_MAINTENANCE, + ACCOUNT_ACTIVATION, + ACCOUNT_CLOSURE, + CARD_REPLACEMENT, + CARD_DELIVERY, + CARD_CREATE, + CURRENCY_CONVERSION, + INTEREST, + LATE_PAYMENT, + BILL_PAYMENT, + CASH_BACK, + ACCOUNT_TO_ACCOUNT, + CARD_TO_CARD, + DISBURSE, + BILLING_ERROR, + LOSS_WRITE_OFF, + EXPIRED_CARD, + EARLY_DERECOGNITION, + ESCHEATMENT, + INACTIVITY_FEE_DOWN, + PROVISIONAL_CREDIT, + DISPUTE_WON, + SERVICE, + TRANSFER, + } - /** - * 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 + /** + * An enum containing [BookTransferType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BookTransferType] 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 { + ATM_WITHDRAWAL, + ATM_DECLINE, + INTERNATIONAL_ATM_WITHDRAWAL, + INACTIVITY, + STATEMENT, + MONTHLY, + QUARTERLY, + ANNUAL, + CUSTOMER_SERVICE, + ACCOUNT_MAINTENANCE, + ACCOUNT_ACTIVATION, + ACCOUNT_CLOSURE, + CARD_REPLACEMENT, + CARD_DELIVERY, + CARD_CREATE, + CURRENCY_CONVERSION, + INTEREST, + LATE_PAYMENT, + BILL_PAYMENT, + CASH_BACK, + ACCOUNT_TO_ACCOUNT, + CARD_TO_CARD, + DISBURSE, + BILLING_ERROR, + LOSS_WRITE_OFF, + EXPIRED_CARD, + EARLY_DERECOGNITION, + ESCHEATMENT, + INACTIVITY_FEE_DOWN, + PROVISIONAL_CREDIT, + DISPUTE_WON, + SERVICE, + TRANSFER, + /** + * An enum member indicating that [BookTransferType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * 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) { + ATM_WITHDRAWAL -> Value.ATM_WITHDRAWAL + ATM_DECLINE -> Value.ATM_DECLINE + INTERNATIONAL_ATM_WITHDRAWAL -> Value.INTERNATIONAL_ATM_WITHDRAWAL + INACTIVITY -> Value.INACTIVITY + STATEMENT -> Value.STATEMENT + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + CUSTOMER_SERVICE -> Value.CUSTOMER_SERVICE + ACCOUNT_MAINTENANCE -> Value.ACCOUNT_MAINTENANCE + ACCOUNT_ACTIVATION -> Value.ACCOUNT_ACTIVATION + ACCOUNT_CLOSURE -> Value.ACCOUNT_CLOSURE + CARD_REPLACEMENT -> Value.CARD_REPLACEMENT + CARD_DELIVERY -> Value.CARD_DELIVERY + CARD_CREATE -> Value.CARD_CREATE + CURRENCY_CONVERSION -> Value.CURRENCY_CONVERSION + INTEREST -> Value.INTEREST + LATE_PAYMENT -> Value.LATE_PAYMENT + BILL_PAYMENT -> Value.BILL_PAYMENT + CASH_BACK -> Value.CASH_BACK + ACCOUNT_TO_ACCOUNT -> Value.ACCOUNT_TO_ACCOUNT + CARD_TO_CARD -> Value.CARD_TO_CARD + DISBURSE -> Value.DISBURSE + BILLING_ERROR -> Value.BILLING_ERROR + LOSS_WRITE_OFF -> Value.LOSS_WRITE_OFF + EXPIRED_CARD -> Value.EXPIRED_CARD + EARLY_DERECOGNITION -> Value.EARLY_DERECOGNITION + ESCHEATMENT -> Value.ESCHEATMENT + INACTIVITY_FEE_DOWN -> Value.INACTIVITY_FEE_DOWN + PROVISIONAL_CREDIT -> Value.PROVISIONAL_CREDIT + DISPUTE_WON -> Value.DISPUTE_WON + SERVICE -> Value.SERVICE + TRANSFER -> Value.TRANSFER + else -> Value._UNKNOWN + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * 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) { + ATM_WITHDRAWAL -> Known.ATM_WITHDRAWAL + ATM_DECLINE -> Known.ATM_DECLINE + INTERNATIONAL_ATM_WITHDRAWAL -> Known.INTERNATIONAL_ATM_WITHDRAWAL + INACTIVITY -> Known.INACTIVITY + STATEMENT -> Known.STATEMENT + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + CUSTOMER_SERVICE -> Known.CUSTOMER_SERVICE + ACCOUNT_MAINTENANCE -> Known.ACCOUNT_MAINTENANCE + ACCOUNT_ACTIVATION -> Known.ACCOUNT_ACTIVATION + ACCOUNT_CLOSURE -> Known.ACCOUNT_CLOSURE + CARD_REPLACEMENT -> Known.CARD_REPLACEMENT + CARD_DELIVERY -> Known.CARD_DELIVERY + CARD_CREATE -> Known.CARD_CREATE + CURRENCY_CONVERSION -> Known.CURRENCY_CONVERSION + INTEREST -> Known.INTEREST + LATE_PAYMENT -> Known.LATE_PAYMENT + BILL_PAYMENT -> Known.BILL_PAYMENT + CASH_BACK -> Known.CASH_BACK + ACCOUNT_TO_ACCOUNT -> Known.ACCOUNT_TO_ACCOUNT + CARD_TO_CARD -> Known.CARD_TO_CARD + DISBURSE -> Known.DISBURSE + BILLING_ERROR -> Known.BILLING_ERROR + LOSS_WRITE_OFF -> Known.LOSS_WRITE_OFF + EXPIRED_CARD -> Known.EXPIRED_CARD + EARLY_DERECOGNITION -> Known.EARLY_DERECOGNITION + ESCHEATMENT -> Known.ESCHEATMENT + INACTIVITY_FEE_DOWN -> Known.INACTIVITY_FEE_DOWN + PROVISIONAL_CREDIT -> Known.PROVISIONAL_CREDIT + DISPUTE_WON -> Known.DISPUTE_WON + SERVICE -> Known.SERVICE + TRANSFER -> Known.TRANSFER + else -> throw LithicInvalidDataException("Unknown BookTransferType: $value") + } - fun toBuilder() = Builder().from(this) + /** + * 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") + } - companion object { + private var validated: Boolean = false - /** - * 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() - } + fun validate(): BookTransferType = apply { + if (validated) { + return@apply + } - /** A builder for [CardTransaction]. */ - class Builder internal constructor() { + known() + validated = true + } - 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() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - @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() - } + /** + * 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 - /** Globally unique identifier. */ - fun token(token: String) = token(JsonField.of(token)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 } + return other is BookTransferType && value == other.value + } - /** The token for the account associated with this transaction. */ - fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + override fun hashCode() = value.hashCode() - /** - * 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 + override fun toString() = value.toString() } - /** - * 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)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for [Builder.acquirerFee]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun acquirerFee(acquirerFee: Long) = acquirerFee(acquirerFee as Long?) + return other is BookTransferEvent && + token == other.token && + amount == other.amount && + created == other.created && + detailedResults == other.detailedResults && + memo == other.memo && + result == other.result && + subtype == other.subtype && + type == other.type && + additionalProperties == other.additionalProperties + } - /** Alias for calling [Builder.acquirerFee] with `acquirerFee.orElse(null)`. */ - fun acquirerFee(acquirerFee: Optional) = acquirerFee(acquirerFee.getOrNull()) + private val hashCode: Int by lazy { + Objects.hash( + token, + amount, + created, + detailedResults, + memo, + result, + subtype, + type, + additionalProperties, + ) + } - /** - * 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 } + override fun hashCode(): Int = hashCode - /** - * 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)) + override fun toString() = + "BookTransferEvent{token=$token, amount=$amount, created=$created, detailedResults=$detailedResults, memo=$memo, result=$result, subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [Builder.acquirerReferenceNumber] with - * `acquirerReferenceNumber.orElse(null)`. - */ - @Deprecated("deprecated") - fun acquirerReferenceNumber(acquirerReferenceNumber: Optional) = - acquirerReferenceNumber(acquirerReferenceNumber.getOrNull()) + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.acquirerReferenceNumber] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - @Deprecated("deprecated") - fun acquirerReferenceNumber(acquirerReferenceNumber: JsonField) = apply { - this.acquirerReferenceNumber = acquirerReferenceNumber - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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)) + companion object { - /** - * 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 } + @JvmField val CARD = of("CARD") - fun amounts(amounts: Transaction.TransactionAmounts) = amounts(JsonField.of(amounts)) + @JvmField val PAYMENT = of("PAYMENT") - /** - * 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 - } + @JvmField val TRANSFER = of("TRANSFER") - /** - * The authorization amount of the transaction in the anticipated settlement currency. - */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: Long?) = - authorizationAmount(JsonField.ofNullable(authorizationAmount)) + @JvmField val INTERNAL = of("INTERNAL") - /** - * Alias for [Builder.authorizationAmount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: Long) = - authorizationAmount(authorizationAmount as Long?) + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") - /** - * Alias for calling [Builder.authorizationAmount] with - * `authorizationAmount.orElse(null)`. - */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: Optional) = - authorizationAmount(authorizationAmount.getOrNull()) + @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, + } /** - * Sets [Builder.authorizationAmount] to an arbitrary JSON value. + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. * - * 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. + * 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. */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: JsonField) = apply { - this.authorizationAmount = authorizationAmount + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, } /** - * A fixed-width 6-digit numeric identifier that can be used to identify a transaction - * with networks. + * 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 authorizationCode(authorizationCode: String?) = - authorizationCode(JsonField.ofNullable(authorizationCode)) + 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 + } /** - * Alias for calling [Builder.authorizationCode] with `authorizationCode.orElse(null)`. + * 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 authorizationCode(authorizationCode: Optional) = - authorizationCode(authorizationCode.getOrNull()) + 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") + } /** - * Sets [Builder.authorizationCode] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * 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. + * 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 authorizationCode(authorizationCode: JsonField) = apply { - this.authorizationCode = authorizationCode - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - fun avs(avs: Transaction.Avs?) = avs(JsonField.ofNullable(avs)) + private var validated: Boolean = false - /** Alias for calling [Builder.avs] with `avs.orElse(null)`. */ - fun avs(avs: Optional) = avs(avs.getOrNull()) + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } - /** - * 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 } + known() + validated = true + } - /** Token for the card used in this transaction. */ - fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Sets [Builder.cardToken] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun cardholderAuthentication( - cardholderAuthentication: Transaction.CardholderAuthentication? - ) = cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [Builder.cardholderAuthentication] with - * `cardholderAuthentication.orElse(null)`. - */ - fun cardholderAuthentication( - cardholderAuthentication: Optional - ) = cardholderAuthentication(cardholderAuthentication.getOrNull()) + return other is TransactionFamilyTypes && value == other.value + } - /** - * 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 } + override fun hashCode() = value.hashCode() - /** Date and time when the transaction first occurred. UTC time zone. */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + override fun toString() = value.toString() + } + + class TransactionResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.created] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - fun created(created: JsonField) = apply { this.created = created } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun merchant(merchant: Transaction.Merchant) = merchant(JsonField.of(merchant)) + companion object { - /** - * 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 - } + @JvmField val APPROVED = of("APPROVED") - /** Analogous to the 'amount', but in the merchant currency. */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: Long?) = - merchantAmount(JsonField.ofNullable(merchantAmount)) + @JvmField val DECLINED = of("DECLINED") - /** - * Alias for [Builder.merchantAmount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } - /** Alias for calling [Builder.merchantAmount] with `merchantAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: Optional) = - merchantAmount(merchantAmount.getOrNull()) + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } /** - * Sets [Builder.merchantAmount] to an arbitrary JSON value. + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. * - * 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. + * 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. */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: JsonField) = apply { - this.merchantAmount = merchantAmount + enum class Value { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] was instantiated with an + * unknown value. + */ + _UNKNOWN, } - /** Analogous to the 'authorization_amount', but in the merchant currency. */ - @Deprecated("deprecated") - fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long?) = - merchantAuthorizationAmount(JsonField.ofNullable(merchantAuthorizationAmount)) - /** - * Alias for [Builder.merchantAuthorizationAmount]. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * 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)`. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - @Deprecated("deprecated") - fun merchantAuthorizationAmount(merchantAuthorizationAmount: Optional) = - merchantAuthorizationAmount(merchantAuthorizationAmount.getOrNull()) + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } /** - * Sets [Builder.merchantAuthorizationAmount] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's 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. + * 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. */ - @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)) + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } /** - * Sets [Builder.merchantCurrency] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * 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. + * 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. */ - @Deprecated("deprecated") - fun merchantCurrency(merchantCurrency: JsonField) = apply { - this.merchantCurrency = merchantCurrency - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - /** - * 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)) + private var validated: Boolean = false - /** Alias for calling [Builder.network] with `network.orElse(null)`. */ - fun network(network: Optional) = network(network.getOrNull()) + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } - /** - * 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 } + known() + validated = true + } - /** - * 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)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Alias for [Builder.networkRiskScore]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun networkRiskScore(networkRiskScore: Long) = - networkRiskScore(networkRiskScore as Long?) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Alias for calling [Builder.networkRiskScore] with `networkRiskScore.orElse(null)`. - */ - fun networkRiskScore(networkRiskScore: Optional) = - networkRiskScore(networkRiskScore.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 + return other is TransactionResult && value == other.value } - fun pos(pos: Transaction.Pos) = pos(JsonField.of(pos)) + override fun hashCode() = value.hashCode() - /** - * 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 } + override fun toString() = value.toString() + } - fun result(result: Transaction.DeclineResult) = result(JsonField.of(result)) + /** The status of the transaction */ + class TransactionStatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.result] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - fun result(result: JsonField) = apply { - this.result = result - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** The settled amount of the transaction in the settlement currency. */ - @Deprecated("deprecated") - fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + companion object { - /** - * 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 - } + @JvmField val PENDING = of("PENDING") - /** Status of the transaction. */ - fun status(status: Transaction.Status) = status(JsonField.of(status)) + @JvmField val SETTLED = of("SETTLED") - /** - * 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 } + @JvmField val DECLINED = of("DECLINED") - fun tokenInfo(tokenInfo: Transaction.TokenInfo?) = - tokenInfo(JsonField.ofNullable(tokenInfo)) + @JvmField val REVERSED = of("REVERSED") - /** Alias for calling [Builder.tokenInfo] with `tokenInfo.orElse(null)`. */ - fun tokenInfo(tokenInfo: Optional) = - tokenInfo(tokenInfo.getOrNull()) + @JvmField val CANCELED = of("CANCELED") - /** - * 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 + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) } - /** Date and time when the transaction last updated. UTC time zone. */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } /** - * Sets [Builder.updated] to an arbitrary JSON value. + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. * - * 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. + * 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. */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - fun events(events: List) = events(JsonField.of(events)) + enum class Value { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.events] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown 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. + * 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 events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + else -> Value._UNKNOWN + } /** - * Adds a single [Transaction.TransactionEvent] to [events]. + * Returns an enum member corresponding to this class instance's value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * 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 addEvent(event: Transaction.TransactionEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { - checkKnown("events", it).add(event) - } - } - - fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + 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") + } /** - * Sets [Builder.family] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * 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. + * 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 family(family: JsonField) = apply { this.family = family } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + known() + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * 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() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - 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(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): CardTransaction = apply { - if (validated) { - return@apply + return other is TransactionStatus && value == other.value } - 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 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + class TransactionSeries + private constructor( + private val relatedTransactionEventToken: JsonField, + private val relatedTransactionToken: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * 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 { + @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()) /** - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @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, - } + fun relatedTransactionEventToken(): Optional = + relatedTransactionEventToken.getOptional("related_transaction_event_token") /** - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - enum class Value { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, - /** - * An enum member indicating that [TransactionFamilyTypes] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun relatedTransactionToken(): Optional = + relatedTransactionToken.getOptional("related_transaction_token") /** - * 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. + * @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 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 - } + fun type(): String = type.getRequired("type") /** - * 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. + * Returns the raw JSON value of [relatedTransactionEventToken]. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field + * has an unexpected type. */ - 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") - } + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken /** - * 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. + * Returns the raw JSON value of [relatedTransactionToken]. * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an + * unexpected 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 - } + @JsonProperty("related_transaction_token") + @ExcludeMissing + fun _relatedTransactionToken(): JsonField = relatedTransactionToken /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [type]. * - * Used for best match union deserialization. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - return other is TransactionFamilyTypes && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - 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 { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * 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 + fun toBuilder() = Builder().from(this) companion object { - @JvmField val PENDING = of("PENDING") - - @JvmField val SETTLED = of("SETTLED") + /** + * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val DECLINED = of("DECLINED") + /** A builder for [TransactionSeries]. */ + class Builder internal constructor() { - @JvmField val REVERSED = of("REVERSED") + private var relatedTransactionEventToken: JsonField? = null + private var relatedTransactionToken: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val CANCELED = of("CANCELED") + @JvmSynthetic + internal fun from(transactionSeries: TransactionSeries) = apply { + relatedTransactionEventToken = transactionSeries.relatedTransactionEventToken + relatedTransactionToken = transactionSeries.relatedTransactionToken + type = transactionSeries.type + additionalProperties = transactionSeries.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) - } + fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = + relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) - /** An enum containing [TransactionStatus]'s known values. */ - enum class Known { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - } + /** + * Alias for calling [Builder.relatedTransactionEventToken] with + * `relatedTransactionEventToken.orElse(null)`. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: Optional) = + relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) - /** - * 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. + * 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. */ - _UNKNOWN, - } + fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = + apply { + this.relatedTransactionEventToken = relatedTransactionEventToken + } - /** - * 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 + 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 } - /** - * 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") + 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) } - /** - * 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") + 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(): TransactionStatus = apply { + fun validate(): TransactionSeries = apply { if (validated) { return@apply } - known() + relatedTransactionEventToken() + relatedTransactionToken() + type() validated = true } @@ -5161,19 +5437,37 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @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 other is TransactionStatus && value == other.value + return other is TransactionSeries && + relatedTransactionEventToken == other.relatedTransactionEventToken && + relatedTransactionToken == other.relatedTransactionToken && + type == other.type && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + relatedTransactionEventToken, + relatedTransactionToken, + type, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -5181,64 +5475,44 @@ private constructor( return true } - return other is CardTransaction && + return other is BookTransferTransaction && 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 && + category == other.category && created == other.created && - merchant == other.merchant && - merchantAmount == other.merchantAmount && - merchantAuthorizationAmount == other.merchantAuthorizationAmount && - merchantCurrency == other.merchantCurrency && - network == other.network && - networkRiskScore == other.networkRiskScore && - pos == other.pos && + currency == other.currency && + events == other.events && + family == other.family && + fromFinancialAccountToken == other.fromFinancialAccountToken && + pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && - tokenInfo == other.tokenInfo && + toFinancialAccountToken == other.toFinancialAccountToken && updated == other.updated && - events == other.events && - family == other.family && + externalId == other.externalId && + externalResource == other.externalResource && + transactionSeries == other.transactionSeries && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( token, - accountToken, - acquirerFee, - acquirerReferenceNumber, - amount, - amounts, - authorizationAmount, - authorizationCode, - avs, - cardToken, - cardholderAuthentication, + category, created, - merchant, - merchantAmount, - merchantAuthorizationAmount, - merchantCurrency, - network, - networkRiskScore, - pos, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, result, settledAmount, status, - tokenInfo, + toFinancialAccountToken, updated, - events, - family, + externalId, + externalResource, + transactionSeries, additionalProperties, ) } @@ -5246,122 +5520,175 @@ private constructor( 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}" + "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}" } - /** Payment transaction */ - class PaymentTransaction + /** Base class for all transaction types in the ledger service */ + class CardTransaction 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 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 source: JsonField, - private val status: JsonField, + private val status: JsonField, + private val tokenInfo: JsonField, private val updated: JsonField, - private val currency: JsonField, - private val expectedReleaseDate: JsonField, - private val externalBankAccountToken: JsonField, - private val userDefinedId: JsonField, + private val events: JsonField>, + private val family: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("category") + @JsonProperty("account_token") @ExcludeMissing - category: JsonField = JsonMissing.of(), - @JsonProperty("created") + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_fee") @ExcludeMissing - created: JsonField = JsonMissing.of(), - @JsonProperty("descriptor") + acquirerFee: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_reference_number") @ExcludeMissing - descriptor: JsonField = JsonMissing.of(), - @JsonProperty("direction") + acquirerReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("amounts") @ExcludeMissing - direction: JsonField = JsonMissing.of(), - @JsonProperty("events") + amounts: JsonField = JsonMissing.of(), + @JsonProperty("authorization_amount") @ExcludeMissing - events: JsonField> = JsonMissing.of(), - @JsonProperty("family") + authorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("authorization_code") @ExcludeMissing - family: JsonField = JsonMissing.of(), - @JsonProperty("financial_account_token") + authorizationCode: JsonField = JsonMissing.of(), + @JsonProperty("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing - financialAccountToken: JsonField = JsonMissing.of(), - @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), - @JsonProperty("method_attributes") + cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_authentication") @ExcludeMissing - methodAttributes: JsonField = JsonMissing.of(), - @JsonProperty("pending_amount") + cardholderAuthentication: JsonField = + JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing - pendingAmount: JsonField = JsonMissing.of(), - @JsonProperty("related_account_tokens") + created: JsonField = JsonMissing.of(), + @JsonProperty("merchant") @ExcludeMissing - relatedAccountTokens: JsonField = JsonMissing.of(), + 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(), + 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(), + status: JsonField = JsonMissing.of(), + @JsonProperty("token_info") + @ExcludeMissing + tokenInfo: 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") + @JsonProperty("events") @ExcludeMissing - externalBankAccountToken: JsonField = JsonMissing.of(), - @JsonProperty("user_defined_id") + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") @ExcludeMissing - userDefinedId: JsonField = JsonMissing.of(), + family: JsonField = JsonMissing.of(), ) : this( token, - category, + accountToken, + acquirerFee, + acquirerReferenceNumber, + amount, + amounts, + authorizationAmount, + authorizationCode, + avs, + cardToken, + cardholderAuthentication, created, - descriptor, - direction, - events, - family, - financialAccountToken, - method, - methodAttributes, - pendingAmount, - relatedAccountTokens, + merchant, + merchantAmount, + merchantAuthorizationAmount, + merchantCurrency, + network, + networkRiskScore, + pos, result, settledAmount, - source, status, + tokenInfo, updated, - currency, - expectedReleaseDate, - externalBankAccountToken, - userDefinedId, + 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() + /** - * Unique identifier for the transaction + * 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). @@ -5369,1229 +5696,3888 @@ private constructor( fun token(): String = token.getRequired("token") /** - * Transaction category + * 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 category(): TransactionCategory = category.getRequired("category") + fun accountToken(): String = accountToken.getRequired("account_token") /** - * ISO 8601 timestamp of when the transaction was created + * 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). */ - fun created(): OffsetDateTime = created.getRequired("created") + @Deprecated("deprecated") fun amount(): Long = amount.getRequired("amount") /** - * 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 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 descriptor(): String = descriptor.getRequired("descriptor") + 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 other is TransactionFamilyTypes && value == other.value + } + + 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 other is TransactionStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + 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, + ) + } + + 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 [PaymentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: PaymentEvent) = 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)) - /** - * 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") + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) - /** - * 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") + /** + * 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 + } - /** - * @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") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * 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") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * 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") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * 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") + /** + * 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(), + ) + } - /** - * 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") + private var validated: Boolean = false - /** - * 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") + fun validate(): PaymentTransaction = apply { + if (validated) { + return@apply + } - /** - * 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") + token() + category().validate() + created() + descriptor() + direction().validate() + events().forEach { it.validate() } + family().validate() + financialAccountToken() + method().validate() + methodAttributes().validate() + pendingAmount() + relatedAccountTokens().validate() + result().validate() + settledAmount() + source().validate() + status().validate() + updated() + currency() + expectedReleaseDate() + externalBankAccountToken() + userDefinedId() + validated = true + } - /** - * 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") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * ISO 8601 timestamp of when the transaction was last updated + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @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). + * Used for best match union deserialization. */ - fun updated(): OffsetDateTime = updated.getRequired("updated") + @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()?.sumOf { it.validity().toInt() } ?: 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) - /** - * 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") + /** Transaction category */ + class TransactionCategory + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * 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 - /** - * 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") + companion object { - /** - * 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") + @JvmField val ACH = of("ACH") - /** - * 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 + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") - /** - * 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 + @JvmField val CARD = of("CARD") - /** - * 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 + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") - /** - * 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 + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") - /** - * 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 + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") - /** - * 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 + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") - /** - * 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 + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") - /** - * 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 + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") - /** - * 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 + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") - /** - * 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 + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") - /** - * 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 + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") - /** - * 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 + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") - /** - * 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 + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } - /** - * 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 + /** 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, + } - /** - * 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 + /** + * 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") + } - /** - * 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 + private var validated: Boolean = false - /** - * 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 + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } - /** - * 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 + known() + validated = true + } - /** - * 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 + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** - * 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 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 - /** - * 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is TransactionCategory && value == other.value + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode() = value.hashCode() - fun toBuilder() = Builder().from(this) + override fun toString() = value.toString() + } - companion object { + /** Transfer direction */ + class Direction @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns a mutable builder for constructing an instance of [PaymentTransaction]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .token() - * .category() - * .created() - * .descriptor() - * .direction() - * .events() - * .family() - * .financialAccountToken() - * .method() - * .methodAttributes() - * .pendingAmount() - * .relatedAccountTokens() - * .result() - * .settledAmount() - * .source() - * .status() - * .updated() - * ``` + * 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. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [PaymentTransaction]. */ - class Builder internal constructor() { + companion object { - 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() + @JvmField val CREDIT = of("CREDIT") - @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() + @JvmField val DEBIT = of("DEBIT") + + @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) } - /** Unique identifier for the transaction */ - fun token(token: String) = token(JsonField.of(token)) + /** An enum containing [Direction]'s known values. */ + enum class Known { + CREDIT, + DEBIT, + } /** - * Sets [Builder.token] to an arbitrary JSON value. + * An enum containing [Direction]'s known values, as well as an [_UNKNOWN] member. * - * 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. + * 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. */ - fun token(token: JsonField) = apply { this.token = token } + enum class Value { + CREDIT, + DEBIT, + /** + * An enum member indicating that [Direction] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** Transaction category */ - fun category(category: TransactionCategory) = category(JsonField.of(category)) + /** + * 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 + } /** - * Sets [Builder.category] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun category(category: JsonField) = apply { - this.category = category + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Direction && value == other.value } - /** ISO 8601 timestamp of when the transaction was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + override fun hashCode() = value.hashCode() - /** - * 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 } + override fun toString() = value.toString() + } - /** Transaction descriptor */ - fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + /** Payment Event */ + class PaymentEvent + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val result: JsonField, + private val type: JsonField, + private val detailedResults: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("detailed_results") + @ExcludeMissing + detailedResults: JsonField> = JsonMissing.of(), + ) : this(token, amount, created, result, type, detailedResults, mutableMapOf()) /** - * Sets [Builder.descriptor] to an arbitrary JSON value. + * Globally unique identifier. * - * 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. + * @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(descriptor: JsonField) = apply { this.descriptor = descriptor } - - /** Transfer direction */ - fun direction(direction: Direction) = direction(JsonField.of(direction)) + fun token(): String = token.getRequired("token") /** - * Sets [Builder.direction] to an arbitrary JSON value. + * Amount of the financial event that has been settled in the currency's smallest unit + * (e.g., cents). * - * 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. + * @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: JsonField) = apply { this.direction = direction } - - /** List of transaction events */ - fun events(events: List) = events(JsonField.of(events)) + fun amount(): Long = amount.getRequired("amount") /** - * Sets [Builder.events] to an arbitrary JSON value. + * Date and time when the financial event occurred. UTC time zone. * - * 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. + * @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(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun created(): OffsetDateTime = created.getRequired("created") /** - * Adds a single [JsonValue] to [events]. + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @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 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. + fun result(): Result = result.getRequired("result") + + /** + * Event types: + * - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending approval/release + * from an ACH hold. + * - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process. + * - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled. + * - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to the + * Federal Reserve. + * - `ACH_ORIGINATION_SETTLED` - ACH origination has settled. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository + * Financial Institution. + * - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder. + * - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt. + * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository + * Financial Institution. * - * 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. + * @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(family: JsonField) = apply { this.family = family } - - /** Financial account token */ - fun financialAccountToken(financialAccountToken: String) = - financialAccountToken(JsonField.of(financialAccountToken)) + fun type(): Type = type.getRequired("type") /** - * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * More detailed reasons for the event * - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - fun financialAccountToken(financialAccountToken: JsonField) = apply { - this.financialAccountToken = financialAccountToken - } - - /** Transfer method */ - fun method(method: Method) = method(JsonField.of(method)) + fun detailedResults(): Optional> = + detailedResults.getOptional("detailed_results") /** - * Sets [Builder.method] to an arbitrary JSON value. + * Returns the raw JSON value of [token]. * - * 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. + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. */ - fun method(method: JsonField) = apply { this.method = method } - - /** Method-specific attributes */ - fun methodAttributes(methodAttributes: MethodAttributes) = - methodAttributes(JsonField.of(methodAttributes)) + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** - * Sets [Builder.methodAttributes] to an arbitrary JSON value. + * Returns the raw JSON value of [amount]. * - * 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. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - 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)) + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * Returns the raw JSON value of [created]. * - * 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. + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - fun pendingAmount(pendingAmount: JsonField) = apply { - this.pendingAmount = pendingAmount - } - - /** Related account tokens for the transaction */ - fun relatedAccountTokens(relatedAccountTokens: RelatedAccountTokens) = - relatedAccountTokens(JsonField.of(relatedAccountTokens)) + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * Returns the raw JSON value of [result]. * - * 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. + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. */ - fun relatedAccountTokens(relatedAccountTokens: JsonField) = - apply { - this.relatedAccountTokens = relatedAccountTokens - } - - /** Transaction result */ - fun result(result: TransactionResult) = result(JsonField.of(result)) + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** - * Sets [Builder.result] to an arbitrary JSON value. + * Returns the raw JSON value of [type]. * - * 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. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun result(result: JsonField) = apply { this.result = result } - - /** Settled amount in cents */ - fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** - * Sets [Builder.settledAmount] to an arbitrary JSON value. + * Returns the raw JSON value of [detailedResults]. * - * 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. + * Unlike [detailedResults], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun settledAmount(settledAmount: JsonField) = apply { - this.settledAmount = settledAmount + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** Transaction source */ - fun source(source: Source) = source(JsonField.of(source)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * 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 } + fun toBuilder() = Builder().from(this) - /** The status of the transaction */ - fun status(status: TransactionStatus) = status(JsonField.of(status)) + companion object { - /** - * 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 } + /** + * Returns a mutable builder for constructing an instance of [PaymentEvent]. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .created() + * .result() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** ISO 8601 timestamp of when the transaction was last updated */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + /** A builder for [PaymentEvent]. */ + class Builder internal constructor() { - /** - * 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 } + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var result: JsonField? = null + private var type: JsonField? = null + private var detailedResults: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** Currency of the transaction in ISO 4217 format */ - fun currency(currency: String) = currency(JsonField.of(currency)) + @JvmSynthetic + internal fun from(paymentEvent: PaymentEvent) = apply { + token = paymentEvent.token + amount = paymentEvent.amount + created = paymentEvent.created + result = paymentEvent.result + type = paymentEvent.type + detailedResults = paymentEvent.detailedResults.map { it.toMutableList() } + additionalProperties = paymentEvent.additionalProperties.toMutableMap() + } - /** - * 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 } + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) - /** Expected release date for the transaction */ - fun expectedReleaseDate(expectedReleaseDate: LocalDate?) = - expectedReleaseDate(JsonField.ofNullable(expectedReleaseDate)) + /** + * 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 } + + /** + * Amount of the financial event that has been settled in the currency's smallest + * unit (e.g., cents). + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) - /** - * Alias for calling [Builder.expectedReleaseDate] with - * `expectedReleaseDate.orElse(null)`. - */ - fun expectedReleaseDate(expectedReleaseDate: Optional) = - expectedReleaseDate(expectedReleaseDate.getOrNull()) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - /** - * 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 - } + /** Date and time when the financial event occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) - /** External bank account token */ - fun externalBankAccountToken(externalBankAccountToken: String?) = - externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) + /** + * 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 } - /** - * Alias for calling [Builder.externalBankAccountToken] with - * `externalBankAccountToken.orElse(null)`. - */ - fun externalBankAccountToken(externalBankAccountToken: Optional) = - externalBankAccountToken(externalBankAccountToken.getOrNull()) + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + fun result(result: Result) = result(JsonField.of(result)) - /** - * 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 - } + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] 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 } - /** User-defined identifier */ - fun userDefinedId(userDefinedId: String?) = - userDefinedId(JsonField.ofNullable(userDefinedId)) + /** + * Event types: + * - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending + * approval/release from an ACH hold. + * - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process. + * - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled. + * - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to + * the Federal Reserve. + * - `ACH_ORIGINATION_SETTLED` - ACH origination has settled. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository + * Financial Institution. + * - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder. + * - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt. + * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available + * balance. + * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository + * Financial Institution. + */ + fun type(type: Type) = type(JsonField.of(type)) - /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ - fun userDefinedId(userDefinedId: Optional) = - userDefinedId(userDefinedId.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } - /** - * 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 - } + /** More detailed reasons for the event */ + fun detailedResults(detailedResults: List) = + detailedResults(JsonField.of(detailedResults)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.detailedResults] to an arbitrary JSON value. + * + * You should usually call [Builder.detailedResults] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun detailedResults(detailedResults: JsonField>) = apply { + this.detailedResults = detailedResults.map { it.toMutableList() } + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Adds a single [DetailedResult] to [detailedResults]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDetailedResult(detailedResult: DetailedResult) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).also { + checkKnown("detailedResults", it).add(detailedResult) + } + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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(), - ) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): PaymentTransaction = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [PaymentEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .created() + * .result() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentEvent = + PaymentEvent( + checkRequired("token", token), + checkRequired("amount", amount), + checkRequired("created", created), + checkRequired("result", result), + checkRequired("type", type), + (detailedResults ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - 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 - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + fun validate(): PaymentEvent = apply { + if (validated) { + return@apply + } - /** - * 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) + token() + amount() + created() + result().validate() + type().validate() + detailedResults().ifPresent { it.forEach { it.validate() } } + validated = true + } - /** Transaction category */ - class TransactionCategory - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Returns this class instance's raw value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (detailedResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - companion object { + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + class Result @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmField val ACH = of("ACH") + /** + * 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 - @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + companion object { - @JvmField val CARD = of("CARD") + @JvmField val APPROVED = of("APPROVED") - @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + @JvmField val DECLINED = of("DECLINED") - @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } - @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + /** + * 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, + } - @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + /** + * 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 + } - @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + /** + * 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") + } - @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + /** + * 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") + } - @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + private var validated: Boolean = false - @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + fun validate(): Result = apply { + if (validated) { + return@apply + } - @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + known() + validated = true + } - @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** 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, + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** - * 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. + * Event types: + * - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending approval/release + * from an ACH hold. + * - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process. + * - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled. + * - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to the + * Federal Reserve. + * - `ACH_ORIGINATION_SETTLED` - ACH origination has settled. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository + * Financial Institution. + * - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder. + * - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt. + * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository + * Financial Institution. */ - 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, + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + /** - * An enum member indicating that [TransactionCategory] was instantiated with an - * unknown value. + * 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. */ - _UNKNOWN, - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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 + companion object { + + @JvmField val ACH_ORIGINATION_CANCELLED = of("ACH_ORIGINATION_CANCELLED") + + @JvmField val ACH_ORIGINATION_INITIATED = of("ACH_ORIGINATION_INITIATED") + + @JvmField val ACH_ORIGINATION_PROCESSED = of("ACH_ORIGINATION_PROCESSED") + + @JvmField val ACH_ORIGINATION_SETTLED = of("ACH_ORIGINATION_SETTLED") + + @JvmField val ACH_ORIGINATION_RELEASED = of("ACH_ORIGINATION_RELEASED") + + @JvmField val ACH_ORIGINATION_REVIEWED = of("ACH_ORIGINATION_REVIEWED") + + @JvmField val ACH_RECEIPT_PROCESSED = of("ACH_RECEIPT_PROCESSED") + + @JvmField val ACH_RECEIPT_SETTLED = of("ACH_RECEIPT_SETTLED") + + @JvmField val ACH_RETURN_INITIATED = of("ACH_RETURN_INITIATED") + + @JvmField val ACH_RETURN_PROCESSED = of("ACH_RETURN_PROCESSED") + + @JvmField val ACH_RETURN_SETTLED = of("ACH_RETURN_SETTLED") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - /** - * 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") + /** An enum containing [Type]'s known values. */ + enum class Known { + ACH_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_SETTLED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, } - /** - * 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") + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACH_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_SETTLED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, } - private var validated: Boolean = false + /** + * 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_ORIGINATION_CANCELLED -> Value.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Value.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Value.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_SETTLED -> Value.ACH_ORIGINATION_SETTLED + ACH_ORIGINATION_RELEASED -> Value.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Value.ACH_ORIGINATION_REVIEWED + ACH_RECEIPT_PROCESSED -> Value.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Value.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Value.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Value.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Value.ACH_RETURN_SETTLED + 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_ORIGINATION_CANCELLED -> Known.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Known.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Known.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_SETTLED -> Known.ACH_ORIGINATION_SETTLED + ACH_ORIGINATION_RELEASED -> Known.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Known.ACH_ORIGINATION_REVIEWED + ACH_RECEIPT_PROCESSED -> Known.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Known.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Known.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Known.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Known.ACH_RETURN_SETTLED + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 + } - fun validate(): TransactionCategory = apply { - if (validated) { - return@apply + return other is Type && value == other.value } - known() - validated = true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + class DetailedResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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 + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is TransactionCategory && value == other.value - } + @JvmField val APPROVED = of("APPROVED") - override fun hashCode() = value.hashCode() + @JvmField val FUNDS_INSUFFICIENT = of("FUNDS_INSUFFICIENT") - override fun toString() = value.toString() - } + @JvmField val ACCOUNT_INVALID = of("ACCOUNT_INVALID") - /** Transfer direction */ - class Direction @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmField + val PROGRAM_TRANSACTION_LIMIT_EXCEEDED = + of("PROGRAM_TRANSACTION_LIMIT_EXCEEDED") - /** - * 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 + @JvmField val PROGRAM_DAILY_LIMIT_EXCEEDED = of("PROGRAM_DAILY_LIMIT_EXCEEDED") - companion object { + @JvmField + val PROGRAM_MONTHLY_LIMIT_EXCEEDED = of("PROGRAM_MONTHLY_LIMIT_EXCEEDED") - @JvmField val CREDIT = of("CREDIT") + @JvmStatic fun of(value: String) = DetailedResult(JsonField.of(value)) + } - @JvmField val DEBIT = of("DEBIT") + /** An enum containing [DetailedResult]'s known values. */ + enum class Known { + APPROVED, + FUNDS_INSUFFICIENT, + ACCOUNT_INVALID, + PROGRAM_TRANSACTION_LIMIT_EXCEEDED, + PROGRAM_DAILY_LIMIT_EXCEEDED, + PROGRAM_MONTHLY_LIMIT_EXCEEDED, + } - @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) - } + /** + * An enum containing [DetailedResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DetailedResult] 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, + FUNDS_INSUFFICIENT, + ACCOUNT_INVALID, + PROGRAM_TRANSACTION_LIMIT_EXCEEDED, + PROGRAM_DAILY_LIMIT_EXCEEDED, + PROGRAM_MONTHLY_LIMIT_EXCEEDED, + /** + * An enum member indicating that [DetailedResult] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** An enum containing [Direction]'s known values. */ - enum class Known { - CREDIT, - DEBIT, - } + /** + * 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 + FUNDS_INSUFFICIENT -> Value.FUNDS_INSUFFICIENT + ACCOUNT_INVALID -> Value.ACCOUNT_INVALID + PROGRAM_TRANSACTION_LIMIT_EXCEEDED -> + Value.PROGRAM_TRANSACTION_LIMIT_EXCEEDED + PROGRAM_DAILY_LIMIT_EXCEEDED -> Value.PROGRAM_DAILY_LIMIT_EXCEEDED + PROGRAM_MONTHLY_LIMIT_EXCEEDED -> Value.PROGRAM_MONTHLY_LIMIT_EXCEEDED + else -> Value._UNKNOWN + } - /** - * 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. + * 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. */ - _UNKNOWN, - } + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + FUNDS_INSUFFICIENT -> Known.FUNDS_INSUFFICIENT + ACCOUNT_INVALID -> Known.ACCOUNT_INVALID + PROGRAM_TRANSACTION_LIMIT_EXCEEDED -> + Known.PROGRAM_TRANSACTION_LIMIT_EXCEEDED + PROGRAM_DAILY_LIMIT_EXCEEDED -> Known.PROGRAM_DAILY_LIMIT_EXCEEDED + PROGRAM_MONTHLY_LIMIT_EXCEEDED -> Known.PROGRAM_MONTHLY_LIMIT_EXCEEDED + else -> throw LithicInvalidDataException("Unknown DetailedResult: $value") + } - /** - * 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 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") + } - /** - * 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") - } + private var validated: Boolean = false - /** - * 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") + fun validate(): DetailedResult = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - fun validate(): Direction = apply { - if (validated) { - return@apply - } + /** + * 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 - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false + return other is DetailedResult && value == other.value } - /** - * 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 hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Direction && value == other.value + return other is PaymentEvent && + token == other.token && + amount == other.amount && + created == other.created && + result == other.result && + type == other.type && + detailedResults == other.detailedResults && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + token, + amount, + created, + result, + type, + detailedResults, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentEvent{token=$token, amount=$amount, created=$created, result=$result, type=$type, detailedResults=$detailedResults, additionalProperties=$additionalProperties}" } class TransactionFamilyTypes @@ -7712,10 +10698,13 @@ private constructor( private val externalBankName: JsonField, private val externalBankRoutingNumber: JsonField, private val externalIndividualName: JsonField, + private val imad: JsonField, private val lithicBankName: JsonField, private val lithicBankRoutingNumber: JsonField, private val lithicIndividualName: JsonField, + private val omad: JsonField, private val previousTransfer: JsonField, + private val wireToken: JsonField, private val additionalProperties: MutableMap, ) { @@ -7733,6 +10722,9 @@ private constructor( @JsonProperty("external_individual_name") @ExcludeMissing externalIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("imad") + @ExcludeMissing + imad: JsonField = JsonMissing.of(), @JsonProperty("lithic_bank_name") @ExcludeMissing lithicBankName: JsonField = JsonMissing.of(), @@ -7742,18 +10734,27 @@ private constructor( @JsonProperty("lithic_individual_name") @ExcludeMissing lithicIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("omad") + @ExcludeMissing + omad: JsonField = JsonMissing.of(), @JsonProperty("previous_transfer") @ExcludeMissing previousTransfer: JsonField = JsonMissing.of(), + @JsonProperty("wire_token") + @ExcludeMissing + wireToken: JsonField = JsonMissing.of(), ) : this( wireTransferType, externalBankName, externalBankRoutingNumber, externalIndividualName, + imad, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, + omad, previousTransfer, + wireToken, mutableMapOf(), ) @@ -7794,6 +10795,14 @@ private constructor( fun externalIndividualName(): Optional = externalIndividualName.getOptional("external_individual_name") + /** + * IMAD + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun imad(): Optional = imad.getOptional("imad") + /** * Lithic bank name * @@ -7821,6 +10830,14 @@ private constructor( fun lithicIndividualName(): Optional = lithicIndividualName.getOptional("lithic_individual_name") + /** + * OMAD + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun omad(): Optional = omad.getOptional("omad") + /** * UUID of previous transfer if this is a retry * @@ -7830,6 +10847,14 @@ private constructor( fun previousTransfer(): Optional = previousTransfer.getOptional("previous_transfer") + /** + * Wire token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun wireToken(): Optional = wireToken.getOptional("wire_token") + /** * Returns the raw JSON value of [wireTransferType]. * @@ -7870,6 +10895,14 @@ private constructor( @ExcludeMissing fun _externalIndividualName(): JsonField = externalIndividualName + /** + * Returns the raw JSON value of [imad]. + * + * Unlike [imad], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("imad") @ExcludeMissing fun _imad(): JsonField = imad + /** * Returns the raw JSON value of [lithicBankName]. * @@ -7900,6 +10933,14 @@ private constructor( @ExcludeMissing fun _lithicIndividualName(): JsonField = lithicIndividualName + /** + * Returns the raw JSON value of [omad]. + * + * Unlike [omad], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("omad") @ExcludeMissing fun _omad(): JsonField = omad + /** * Returns the raw JSON value of [previousTransfer]. * @@ -7910,6 +10951,16 @@ private constructor( @ExcludeMissing fun _previousTransfer(): JsonField = previousTransfer + /** + * Returns the raw JSON value of [wireToken]. + * + * Unlike [wireToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wire_token") + @ExcludeMissing + fun _wireToken(): JsonField = wireToken + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7943,10 +10994,13 @@ private constructor( private var externalBankName: JsonField = JsonMissing.of() private var externalBankRoutingNumber: JsonField = JsonMissing.of() private var externalIndividualName: JsonField = JsonMissing.of() + private var imad: JsonField = JsonMissing.of() private var lithicBankName: JsonField = JsonMissing.of() private var lithicBankRoutingNumber: JsonField = JsonMissing.of() private var lithicIndividualName: JsonField = JsonMissing.of() + private var omad: JsonField = JsonMissing.of() private var previousTransfer: JsonField = JsonMissing.of() + private var wireToken: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7955,10 +11009,13 @@ private constructor( externalBankName = wireMethodAttributes.externalBankName externalBankRoutingNumber = wireMethodAttributes.externalBankRoutingNumber externalIndividualName = wireMethodAttributes.externalIndividualName + imad = wireMethodAttributes.imad lithicBankName = wireMethodAttributes.lithicBankName lithicBankRoutingNumber = wireMethodAttributes.lithicBankRoutingNumber lithicIndividualName = wireMethodAttributes.lithicIndividualName + omad = wireMethodAttributes.omad previousTransfer = wireMethodAttributes.previousTransfer + wireToken = wireMethodAttributes.wireToken additionalProperties = wireMethodAttributes.additionalProperties.toMutableMap() } @@ -8045,6 +11102,21 @@ private constructor( this.externalIndividualName = externalIndividualName } + /** IMAD */ + fun imad(imad: String?) = imad(JsonField.ofNullable(imad)) + + /** Alias for calling [Builder.imad] with `imad.orElse(null)`. */ + fun imad(imad: Optional) = imad(imad.getOrNull()) + + /** + * Sets [Builder.imad] to an arbitrary JSON value. + * + * You should usually call [Builder.imad] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imad(imad: JsonField) = apply { this.imad = imad } + /** Lithic bank name */ fun lithicBankName(lithicBankName: String?) = lithicBankName(JsonField.ofNullable(lithicBankName)) @@ -8112,6 +11184,21 @@ private constructor( this.lithicIndividualName = lithicIndividualName } + /** OMAD */ + fun omad(omad: String?) = omad(JsonField.ofNullable(omad)) + + /** Alias for calling [Builder.omad] with `omad.orElse(null)`. */ + fun omad(omad: Optional) = omad(omad.getOrNull()) + + /** + * Sets [Builder.omad] to an arbitrary JSON value. + * + * You should usually call [Builder.omad] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun omad(omad: JsonField) = apply { this.omad = omad } + /** UUID of previous transfer if this is a retry */ fun previousTransfer(previousTransfer: String?) = previousTransfer(JsonField.ofNullable(previousTransfer)) @@ -8134,6 +11221,23 @@ private constructor( this.previousTransfer = previousTransfer } + /** Wire token */ + fun wireToken(wireToken: String?) = wireToken(JsonField.ofNullable(wireToken)) + + /** Alias for calling [Builder.wireToken] with `wireToken.orElse(null)`. */ + fun wireToken(wireToken: Optional) = wireToken(wireToken.getOrNull()) + + /** + * Sets [Builder.wireToken] to an arbitrary JSON value. + * + * You should usually call [Builder.wireToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun wireToken(wireToken: JsonField) = apply { + this.wireToken = wireToken + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8174,10 +11278,13 @@ private constructor( externalBankName, externalBankRoutingNumber, externalIndividualName, + imad, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, + omad, previousTransfer, + wireToken, additionalProperties.toMutableMap(), ) } @@ -8193,10 +11300,13 @@ private constructor( externalBankName() externalBankRoutingNumber() externalIndividualName() + imad() lithicBankName() lithicBankRoutingNumber() lithicIndividualName() + omad() previousTransfer() + wireToken() validated = true } @@ -8220,10 +11330,13 @@ private constructor( (if (externalBankName.asKnown().isPresent) 1 else 0) + (if (externalBankRoutingNumber.asKnown().isPresent) 1 else 0) + (if (externalIndividualName.asKnown().isPresent) 1 else 0) + + (if (imad.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) + (if (omad.asKnown().isPresent) 1 else 0) + + (if (previousTransfer.asKnown().isPresent) 1 else 0) + + (if (wireToken.asKnown().isPresent) 1 else 0) /** Type of wire transfer */ class WireTransferType @@ -8373,10 +11486,13 @@ private constructor( externalBankName == other.externalBankName && externalBankRoutingNumber == other.externalBankRoutingNumber && externalIndividualName == other.externalIndividualName && + imad == other.imad && lithicBankName == other.lithicBankName && lithicBankRoutingNumber == other.lithicBankRoutingNumber && lithicIndividualName == other.lithicIndividualName && + omad == other.omad && previousTransfer == other.previousTransfer && + wireToken == other.wireToken && additionalProperties == other.additionalProperties } @@ -8386,10 +11502,13 @@ private constructor( externalBankName, externalBankRoutingNumber, externalIndividualName, + imad, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, + omad, previousTransfer, + wireToken, additionalProperties, ) } @@ -8397,7 +11516,7 @@ private constructor( 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}" + "WireMethodAttributes{wireTransferType=$wireTransferType, externalBankName=$externalBankName, externalBankRoutingNumber=$externalBankRoutingNumber, externalIndividualName=$externalIndividualName, imad=$imad, lithicBankName=$lithicBankName, lithicBankRoutingNumber=$lithicBankRoutingNumber, lithicIndividualName=$lithicIndividualName, omad=$omad, previousTransfer=$previousTransfer, wireToken=$wireToken, additionalProperties=$additionalProperties}" } } 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 index 906e97465..042108621 100644 --- 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 @@ -419,7 +419,7 @@ private constructor( private val created: JsonField, private val currency: JsonField, private val descriptor: JsonField, - private val events: JsonField>, + private val events: JsonField>, private val family: JsonField, private val financialAccountToken: JsonField, private val pendingAmount: JsonField, @@ -447,7 +447,7 @@ private constructor( descriptor: JsonField = JsonMissing.of(), @JsonProperty("events") @ExcludeMissing - events: JsonField> = JsonMissing.of(), + events: JsonField> = JsonMissing.of(), @JsonProperty("family") @ExcludeMissing family: JsonField = JsonMissing.of(), @@ -532,7 +532,7 @@ private constructor( * @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") + fun events(): List = events.getRequired("events") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -633,7 +633,9 @@ private constructor( * * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Returns the raw JSON value of [family]. @@ -740,7 +742,7 @@ private constructor( private var created: JsonField? = null private var currency: JsonField? = null private var descriptor: JsonField? = null - private var events: JsonField>? = null + private var events: JsonField>? = null private var family: JsonField? = null private var financialAccountToken: JsonField? = null private var pendingAmount: JsonField? = null @@ -831,25 +833,25 @@ private constructor( fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } /** List of transaction events */ - fun events(events: List) = events(JsonField.of(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. + * 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 { + fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } /** - * Adds a single [JsonValue] to [events]. + * Adds a single [FinancialEvent] to [events]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addEvent(event: JsonValue) = apply { + fun addEvent(event: FinancialEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) @@ -1020,7 +1022,7 @@ private constructor( created() currency() descriptor() - events() + events().forEach { it.validate() } family().validate() financialAccountToken() pendingAmount() @@ -1052,7 +1054,7 @@ private constructor( (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) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (family.asKnown().getOrNull()?.validity() ?: 0) + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + (if (pendingAmount.asKnown().isPresent) 1 else 0) + @@ -1262,133 +1264,262 @@ private constructor( override fun toString() = value.toString() } - class TransactionFamilyTypes - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Financial Event */ + class FinancialEvent + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val result: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this(token, amount, created, result, type, mutableMapOf()) /** - * Returns this class instance's raw value. + * Globally unique identifier. * - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @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") + fun token(): Optional = token.getOptional("token") - @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + /** + * Amount of the financial event that has been settled in the currency's smallest unit + * (e.g., cents). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + /** + * Date and time when the financial event occurred. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") - @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) - } + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") - /** An enum containing [TransactionFamilyTypes]'s known values. */ - enum class Known { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, - } + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") /** - * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] - * member. + * Returns the raw JSON value of [token]. * - * 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. + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. */ - enum class Value { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, - /** - * An enum member indicating that [TransactionFamilyTypes] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Returns the raw JSON value of [amount]. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - 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 - } + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * 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. + * Returns the raw JSON value of [created]. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - 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") - } + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [result]. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * 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 [type]. * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") + @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 [FinancialEvent]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FinancialEvent]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var amount: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(financialEvent: FinancialEvent) = apply { + token = financialEvent.token + amount = financialEvent.amount + created = financialEvent.created + result = financialEvent.result + type = financialEvent.type + additionalProperties = financialEvent.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 } + + /** + * Amount of the financial event that has been settled in the currency's smallest + * unit (e.g., cents). + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Date and time when the financial event 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 } + + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + fun result(result: Result) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] 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 } + + fun type(type: FinancialEventType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FinancialEventType] + * 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 [FinancialEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FinancialEvent = + FinancialEvent( + token, + amount, + created, + result, + type, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): TransactionFamilyTypes = apply { + fun validate(): FinancialEvent = apply { if (validated) { return@apply } - known() + token() + amount() + created() + result().ifPresent { it.validate() } + type().ifPresent { it.validate() } validated = true } @@ -1406,273 +1537,830 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + class Result @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is TransactionFamilyTypes && value == other.value - } + /** + * 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 - override fun hashCode() = value.hashCode() + companion object { - override fun toString() = value.toString() - } + @JvmField val APPROVED = of("APPROVED") - /** Transaction result */ - class TransactionResult - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val DECLINED = of("DECLINED") - /** - * 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 { + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } - @JvmField val APPROVED = of("APPROVED") + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - @JvmField val DECLINED = of("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, + } - @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) - } + /** + * 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 + } - /** An enum containing [TransactionResult]'s known values. */ - enum class Known { - APPROVED, - DECLINED, - } + /** + * 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") + } - /** - * 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. + * 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. */ - _UNKNOWN, - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - /** - * 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 - } + private var validated: Boolean = false - /** - * 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") - } + fun validate(): Result = apply { + if (validated) { + return@apply + } - /** - * 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") + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - fun validate(): TransactionResult = apply { - if (validated) { - return@apply + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && value == other.value } - known() - validated = true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + class FinancialEventType + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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 + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is TransactionResult && value == other.value - } + @JvmField val ACH_ORIGINATION_CANCELLED = of("ACH_ORIGINATION_CANCELLED") - override fun hashCode() = value.hashCode() + @JvmField val ACH_ORIGINATION_INITIATED = of("ACH_ORIGINATION_INITIATED") - override fun toString() = value.toString() - } + @JvmField val ACH_ORIGINATION_PROCESSED = of("ACH_ORIGINATION_PROCESSED") - /** The status of the transaction */ - class TransactionStatus - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val ACH_ORIGINATION_RELEASED = of("ACH_ORIGINATION_RELEASED") - /** - * 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 + @JvmField val ACH_ORIGINATION_REVIEWED = of("ACH_ORIGINATION_REVIEWED") - companion object { + @JvmField val ACH_ORIGINATION_SETTLED = of("ACH_ORIGINATION_SETTLED") - @JvmField val PENDING = of("PENDING") + @JvmField val ACH_RECEIPT_PROCESSED = of("ACH_RECEIPT_PROCESSED") - @JvmField val SETTLED = of("SETTLED") + @JvmField val ACH_RECEIPT_SETTLED = of("ACH_RECEIPT_SETTLED") - @JvmField val DECLINED = of("DECLINED") + @JvmField val ACH_RETURN_INITIATED = of("ACH_RETURN_INITIATED") - @JvmField val REVERSED = of("REVERSED") + @JvmField val ACH_RETURN_PROCESSED = of("ACH_RETURN_PROCESSED") - @JvmField val CANCELED = of("CANCELED") + @JvmField val ACH_RETURN_SETTLED = of("ACH_RETURN_SETTLED") - @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) - } + @JvmField val AUTHORIZATION = of("AUTHORIZATION") - /** An enum containing [TransactionStatus]'s known values. */ - enum class Known { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - } + @JvmField val AUTHORIZATION_ADVICE = of("AUTHORIZATION_ADVICE") - /** - * 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, - } + @JvmField val AUTHORIZATION_EXPIRY = of("AUTHORIZATION_EXPIRY") - /** - * 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 - } + @JvmField val AUTHORIZATION_REVERSAL = of("AUTHORIZATION_REVERSAL") - /** - * 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") - } + @JvmField val BALANCE_INQUIRY = of("BALANCE_INQUIRY") - /** - * 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") - } + @JvmField val BILLING_ERROR = of("BILLING_ERROR") - private var validated: Boolean = false + @JvmField val BILLING_ERROR_REVERSAL = of("BILLING_ERROR_REVERSAL") - fun validate(): TransactionStatus = apply { - if (validated) { - return@apply - } + @JvmField val CARD_TO_CARD = of("CARD_TO_CARD") + + @JvmField val CASH_BACK = of("CASH_BACK") + + @JvmField val CASH_BACK_REVERSAL = of("CASH_BACK_REVERSAL") + + @JvmField val CLEARING = of("CLEARING") + + @JvmField val COLLECTION = of("COLLECTION") + + @JvmField val CORRECTION_CREDIT = of("CORRECTION_CREDIT") + + @JvmField val CORRECTION_DEBIT = of("CORRECTION_DEBIT") + + @JvmField val CREDIT_AUTHORIZATION = of("CREDIT_AUTHORIZATION") + + @JvmField val CREDIT_AUTHORIZATION_ADVICE = of("CREDIT_AUTHORIZATION_ADVICE") + + @JvmField val CURRENCY_CONVERSION = of("CURRENCY_CONVERSION") + + @JvmField val CURRENCY_CONVERSION_REVERSAL = of("CURRENCY_CONVERSION_REVERSAL") + + @JvmField val DISPUTE_WON = of("DISPUTE_WON") + + @JvmField val EXTERNAL_ACH_CANCELED = of("EXTERNAL_ACH_CANCELED") + + @JvmField val EXTERNAL_ACH_INITIATED = of("EXTERNAL_ACH_INITIATED") + + @JvmField val EXTERNAL_ACH_RELEASED = of("EXTERNAL_ACH_RELEASED") + + @JvmField val EXTERNAL_ACH_REVERSED = of("EXTERNAL_ACH_REVERSED") + + @JvmField val EXTERNAL_ACH_SETTLED = of("EXTERNAL_ACH_SETTLED") + + @JvmField val EXTERNAL_CHECK_CANCELED = of("EXTERNAL_CHECK_CANCELED") + + @JvmField val EXTERNAL_CHECK_INITIATED = of("EXTERNAL_CHECK_INITIATED") + + @JvmField val EXTERNAL_CHECK_RELEASED = of("EXTERNAL_CHECK_RELEASED") + + @JvmField val EXTERNAL_CHECK_REVERSED = of("EXTERNAL_CHECK_REVERSED") + + @JvmField val EXTERNAL_CHECK_SETTLED = of("EXTERNAL_CHECK_SETTLED") + + @JvmField val EXTERNAL_TRANSFER_CANCELED = of("EXTERNAL_TRANSFER_CANCELED") + + @JvmField val EXTERNAL_TRANSFER_INITIATED = of("EXTERNAL_TRANSFER_INITIATED") + + @JvmField val EXTERNAL_TRANSFER_RELEASED = of("EXTERNAL_TRANSFER_RELEASED") + + @JvmField val EXTERNAL_TRANSFER_REVERSED = of("EXTERNAL_TRANSFER_REVERSED") + + @JvmField val EXTERNAL_TRANSFER_SETTLED = of("EXTERNAL_TRANSFER_SETTLED") + + @JvmField val EXTERNAL_WIRE_CANCELED = of("EXTERNAL_WIRE_CANCELED") + + @JvmField val EXTERNAL_WIRE_INITIATED = of("EXTERNAL_WIRE_INITIATED") + + @JvmField val EXTERNAL_WIRE_RELEASED = of("EXTERNAL_WIRE_RELEASED") + + @JvmField val EXTERNAL_WIRE_REVERSED = of("EXTERNAL_WIRE_REVERSED") + + @JvmField val EXTERNAL_WIRE_SETTLED = of("EXTERNAL_WIRE_SETTLED") + + @JvmField val FINANCIAL_AUTHORIZATION = of("FINANCIAL_AUTHORIZATION") + + @JvmField + val FINANCIAL_CREDIT_AUTHORIZATION = of("FINANCIAL_CREDIT_AUTHORIZATION") + + @JvmField val INTEREST = of("INTEREST") + + @JvmField val INTEREST_REVERSAL = of("INTEREST_REVERSAL") + + @JvmField val INTERNAL_ADJUSTMENT = of("INTERNAL_ADJUSTMENT") + + @JvmField val LATE_PAYMENT = of("LATE_PAYMENT") + + @JvmField val LATE_PAYMENT_REVERSAL = of("LATE_PAYMENT_REVERSAL") + + @JvmField val LOSS_WRITE_OFF = of("LOSS_WRITE_OFF") + + @JvmField val PROVISIONAL_CREDIT = of("PROVISIONAL_CREDIT") + + @JvmField val PROVISIONAL_CREDIT_REVERSAL = of("PROVISIONAL_CREDIT_REVERSAL") + + @JvmField val SERVICE = of("SERVICE") + + @JvmField val RETURN = of("RETURN") + + @JvmField val RETURN_REVERSAL = of("RETURN_REVERSAL") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmField val TRANSFER_INSUFFICIENT_FUNDS = of("TRANSFER_INSUFFICIENT_FUNDS") + + @JvmField val RETURNED_PAYMENT = of("RETURNED_PAYMENT") + + @JvmField val RETURNED_PAYMENT_REVERSAL = of("RETURNED_PAYMENT_REVERSAL") + + @JvmField val LITHIC_NETWORK_PAYMENT = of("LITHIC_NETWORK_PAYMENT") + + @JvmStatic fun of(value: String) = FinancialEventType(JsonField.of(value)) + } + + /** An enum containing [FinancialEventType]'s known values. */ + enum class Known { + ACH_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_ORIGINATION_SETTLED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, + AUTHORIZATION, + AUTHORIZATION_ADVICE, + AUTHORIZATION_EXPIRY, + AUTHORIZATION_REVERSAL, + BALANCE_INQUIRY, + BILLING_ERROR, + BILLING_ERROR_REVERSAL, + CARD_TO_CARD, + CASH_BACK, + CASH_BACK_REVERSAL, + CLEARING, + COLLECTION, + CORRECTION_CREDIT, + CORRECTION_DEBIT, + CREDIT_AUTHORIZATION, + CREDIT_AUTHORIZATION_ADVICE, + CURRENCY_CONVERSION, + CURRENCY_CONVERSION_REVERSAL, + DISPUTE_WON, + EXTERNAL_ACH_CANCELED, + EXTERNAL_ACH_INITIATED, + EXTERNAL_ACH_RELEASED, + EXTERNAL_ACH_REVERSED, + EXTERNAL_ACH_SETTLED, + EXTERNAL_CHECK_CANCELED, + EXTERNAL_CHECK_INITIATED, + EXTERNAL_CHECK_RELEASED, + EXTERNAL_CHECK_REVERSED, + EXTERNAL_CHECK_SETTLED, + EXTERNAL_TRANSFER_CANCELED, + EXTERNAL_TRANSFER_INITIATED, + EXTERNAL_TRANSFER_RELEASED, + EXTERNAL_TRANSFER_REVERSED, + EXTERNAL_TRANSFER_SETTLED, + EXTERNAL_WIRE_CANCELED, + EXTERNAL_WIRE_INITIATED, + EXTERNAL_WIRE_RELEASED, + EXTERNAL_WIRE_REVERSED, + EXTERNAL_WIRE_SETTLED, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + INTEREST, + INTEREST_REVERSAL, + INTERNAL_ADJUSTMENT, + LATE_PAYMENT, + LATE_PAYMENT_REVERSAL, + LOSS_WRITE_OFF, + PROVISIONAL_CREDIT, + PROVISIONAL_CREDIT_REVERSAL, + SERVICE, + RETURN, + RETURN_REVERSAL, + TRANSFER, + TRANSFER_INSUFFICIENT_FUNDS, + RETURNED_PAYMENT, + RETURNED_PAYMENT_REVERSAL, + LITHIC_NETWORK_PAYMENT, + } + + /** + * An enum containing [FinancialEventType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [FinancialEventType] 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_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_ORIGINATION_SETTLED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, + AUTHORIZATION, + AUTHORIZATION_ADVICE, + AUTHORIZATION_EXPIRY, + AUTHORIZATION_REVERSAL, + BALANCE_INQUIRY, + BILLING_ERROR, + BILLING_ERROR_REVERSAL, + CARD_TO_CARD, + CASH_BACK, + CASH_BACK_REVERSAL, + CLEARING, + COLLECTION, + CORRECTION_CREDIT, + CORRECTION_DEBIT, + CREDIT_AUTHORIZATION, + CREDIT_AUTHORIZATION_ADVICE, + CURRENCY_CONVERSION, + CURRENCY_CONVERSION_REVERSAL, + DISPUTE_WON, + EXTERNAL_ACH_CANCELED, + EXTERNAL_ACH_INITIATED, + EXTERNAL_ACH_RELEASED, + EXTERNAL_ACH_REVERSED, + EXTERNAL_ACH_SETTLED, + EXTERNAL_CHECK_CANCELED, + EXTERNAL_CHECK_INITIATED, + EXTERNAL_CHECK_RELEASED, + EXTERNAL_CHECK_REVERSED, + EXTERNAL_CHECK_SETTLED, + EXTERNAL_TRANSFER_CANCELED, + EXTERNAL_TRANSFER_INITIATED, + EXTERNAL_TRANSFER_RELEASED, + EXTERNAL_TRANSFER_REVERSED, + EXTERNAL_TRANSFER_SETTLED, + EXTERNAL_WIRE_CANCELED, + EXTERNAL_WIRE_INITIATED, + EXTERNAL_WIRE_RELEASED, + EXTERNAL_WIRE_REVERSED, + EXTERNAL_WIRE_SETTLED, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + INTEREST, + INTEREST_REVERSAL, + INTERNAL_ADJUSTMENT, + LATE_PAYMENT, + LATE_PAYMENT_REVERSAL, + LOSS_WRITE_OFF, + PROVISIONAL_CREDIT, + PROVISIONAL_CREDIT_REVERSAL, + SERVICE, + RETURN, + RETURN_REVERSAL, + TRANSFER, + TRANSFER_INSUFFICIENT_FUNDS, + RETURNED_PAYMENT, + RETURNED_PAYMENT_REVERSAL, + LITHIC_NETWORK_PAYMENT, + /** + * An enum member indicating that [FinancialEventType] 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_ORIGINATION_CANCELLED -> Value.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Value.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Value.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_RELEASED -> Value.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Value.ACH_ORIGINATION_REVIEWED + ACH_ORIGINATION_SETTLED -> Value.ACH_ORIGINATION_SETTLED + ACH_RECEIPT_PROCESSED -> Value.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Value.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Value.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Value.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Value.ACH_RETURN_SETTLED + AUTHORIZATION -> Value.AUTHORIZATION + AUTHORIZATION_ADVICE -> Value.AUTHORIZATION_ADVICE + AUTHORIZATION_EXPIRY -> Value.AUTHORIZATION_EXPIRY + AUTHORIZATION_REVERSAL -> Value.AUTHORIZATION_REVERSAL + BALANCE_INQUIRY -> Value.BALANCE_INQUIRY + BILLING_ERROR -> Value.BILLING_ERROR + BILLING_ERROR_REVERSAL -> Value.BILLING_ERROR_REVERSAL + CARD_TO_CARD -> Value.CARD_TO_CARD + CASH_BACK -> Value.CASH_BACK + CASH_BACK_REVERSAL -> Value.CASH_BACK_REVERSAL + CLEARING -> Value.CLEARING + COLLECTION -> Value.COLLECTION + CORRECTION_CREDIT -> Value.CORRECTION_CREDIT + CORRECTION_DEBIT -> Value.CORRECTION_DEBIT + CREDIT_AUTHORIZATION -> Value.CREDIT_AUTHORIZATION + CREDIT_AUTHORIZATION_ADVICE -> Value.CREDIT_AUTHORIZATION_ADVICE + CURRENCY_CONVERSION -> Value.CURRENCY_CONVERSION + CURRENCY_CONVERSION_REVERSAL -> Value.CURRENCY_CONVERSION_REVERSAL + DISPUTE_WON -> Value.DISPUTE_WON + EXTERNAL_ACH_CANCELED -> Value.EXTERNAL_ACH_CANCELED + EXTERNAL_ACH_INITIATED -> Value.EXTERNAL_ACH_INITIATED + EXTERNAL_ACH_RELEASED -> Value.EXTERNAL_ACH_RELEASED + EXTERNAL_ACH_REVERSED -> Value.EXTERNAL_ACH_REVERSED + EXTERNAL_ACH_SETTLED -> Value.EXTERNAL_ACH_SETTLED + EXTERNAL_CHECK_CANCELED -> Value.EXTERNAL_CHECK_CANCELED + EXTERNAL_CHECK_INITIATED -> Value.EXTERNAL_CHECK_INITIATED + EXTERNAL_CHECK_RELEASED -> Value.EXTERNAL_CHECK_RELEASED + EXTERNAL_CHECK_REVERSED -> Value.EXTERNAL_CHECK_REVERSED + EXTERNAL_CHECK_SETTLED -> Value.EXTERNAL_CHECK_SETTLED + EXTERNAL_TRANSFER_CANCELED -> Value.EXTERNAL_TRANSFER_CANCELED + EXTERNAL_TRANSFER_INITIATED -> Value.EXTERNAL_TRANSFER_INITIATED + EXTERNAL_TRANSFER_RELEASED -> Value.EXTERNAL_TRANSFER_RELEASED + EXTERNAL_TRANSFER_REVERSED -> Value.EXTERNAL_TRANSFER_REVERSED + EXTERNAL_TRANSFER_SETTLED -> Value.EXTERNAL_TRANSFER_SETTLED + EXTERNAL_WIRE_CANCELED -> Value.EXTERNAL_WIRE_CANCELED + EXTERNAL_WIRE_INITIATED -> Value.EXTERNAL_WIRE_INITIATED + EXTERNAL_WIRE_RELEASED -> Value.EXTERNAL_WIRE_RELEASED + EXTERNAL_WIRE_REVERSED -> Value.EXTERNAL_WIRE_REVERSED + EXTERNAL_WIRE_SETTLED -> Value.EXTERNAL_WIRE_SETTLED + FINANCIAL_AUTHORIZATION -> Value.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Value.FINANCIAL_CREDIT_AUTHORIZATION + INTEREST -> Value.INTEREST + INTEREST_REVERSAL -> Value.INTEREST_REVERSAL + INTERNAL_ADJUSTMENT -> Value.INTERNAL_ADJUSTMENT + LATE_PAYMENT -> Value.LATE_PAYMENT + LATE_PAYMENT_REVERSAL -> Value.LATE_PAYMENT_REVERSAL + LOSS_WRITE_OFF -> Value.LOSS_WRITE_OFF + PROVISIONAL_CREDIT -> Value.PROVISIONAL_CREDIT + PROVISIONAL_CREDIT_REVERSAL -> Value.PROVISIONAL_CREDIT_REVERSAL + SERVICE -> Value.SERVICE + RETURN -> Value.RETURN + RETURN_REVERSAL -> Value.RETURN_REVERSAL + TRANSFER -> Value.TRANSFER + TRANSFER_INSUFFICIENT_FUNDS -> Value.TRANSFER_INSUFFICIENT_FUNDS + RETURNED_PAYMENT -> Value.RETURNED_PAYMENT + RETURNED_PAYMENT_REVERSAL -> Value.RETURNED_PAYMENT_REVERSAL + LITHIC_NETWORK_PAYMENT -> Value.LITHIC_NETWORK_PAYMENT + 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_ORIGINATION_CANCELLED -> Known.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Known.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Known.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_RELEASED -> Known.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Known.ACH_ORIGINATION_REVIEWED + ACH_ORIGINATION_SETTLED -> Known.ACH_ORIGINATION_SETTLED + ACH_RECEIPT_PROCESSED -> Known.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Known.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Known.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Known.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Known.ACH_RETURN_SETTLED + AUTHORIZATION -> Known.AUTHORIZATION + AUTHORIZATION_ADVICE -> Known.AUTHORIZATION_ADVICE + AUTHORIZATION_EXPIRY -> Known.AUTHORIZATION_EXPIRY + AUTHORIZATION_REVERSAL -> Known.AUTHORIZATION_REVERSAL + BALANCE_INQUIRY -> Known.BALANCE_INQUIRY + BILLING_ERROR -> Known.BILLING_ERROR + BILLING_ERROR_REVERSAL -> Known.BILLING_ERROR_REVERSAL + CARD_TO_CARD -> Known.CARD_TO_CARD + CASH_BACK -> Known.CASH_BACK + CASH_BACK_REVERSAL -> Known.CASH_BACK_REVERSAL + CLEARING -> Known.CLEARING + COLLECTION -> Known.COLLECTION + CORRECTION_CREDIT -> Known.CORRECTION_CREDIT + CORRECTION_DEBIT -> Known.CORRECTION_DEBIT + CREDIT_AUTHORIZATION -> Known.CREDIT_AUTHORIZATION + CREDIT_AUTHORIZATION_ADVICE -> Known.CREDIT_AUTHORIZATION_ADVICE + CURRENCY_CONVERSION -> Known.CURRENCY_CONVERSION + CURRENCY_CONVERSION_REVERSAL -> Known.CURRENCY_CONVERSION_REVERSAL + DISPUTE_WON -> Known.DISPUTE_WON + EXTERNAL_ACH_CANCELED -> Known.EXTERNAL_ACH_CANCELED + EXTERNAL_ACH_INITIATED -> Known.EXTERNAL_ACH_INITIATED + EXTERNAL_ACH_RELEASED -> Known.EXTERNAL_ACH_RELEASED + EXTERNAL_ACH_REVERSED -> Known.EXTERNAL_ACH_REVERSED + EXTERNAL_ACH_SETTLED -> Known.EXTERNAL_ACH_SETTLED + EXTERNAL_CHECK_CANCELED -> Known.EXTERNAL_CHECK_CANCELED + EXTERNAL_CHECK_INITIATED -> Known.EXTERNAL_CHECK_INITIATED + EXTERNAL_CHECK_RELEASED -> Known.EXTERNAL_CHECK_RELEASED + EXTERNAL_CHECK_REVERSED -> Known.EXTERNAL_CHECK_REVERSED + EXTERNAL_CHECK_SETTLED -> Known.EXTERNAL_CHECK_SETTLED + EXTERNAL_TRANSFER_CANCELED -> Known.EXTERNAL_TRANSFER_CANCELED + EXTERNAL_TRANSFER_INITIATED -> Known.EXTERNAL_TRANSFER_INITIATED + EXTERNAL_TRANSFER_RELEASED -> Known.EXTERNAL_TRANSFER_RELEASED + EXTERNAL_TRANSFER_REVERSED -> Known.EXTERNAL_TRANSFER_REVERSED + EXTERNAL_TRANSFER_SETTLED -> Known.EXTERNAL_TRANSFER_SETTLED + EXTERNAL_WIRE_CANCELED -> Known.EXTERNAL_WIRE_CANCELED + EXTERNAL_WIRE_INITIATED -> Known.EXTERNAL_WIRE_INITIATED + EXTERNAL_WIRE_RELEASED -> Known.EXTERNAL_WIRE_RELEASED + EXTERNAL_WIRE_REVERSED -> Known.EXTERNAL_WIRE_REVERSED + EXTERNAL_WIRE_SETTLED -> Known.EXTERNAL_WIRE_SETTLED + FINANCIAL_AUTHORIZATION -> Known.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Known.FINANCIAL_CREDIT_AUTHORIZATION + INTEREST -> Known.INTEREST + INTEREST_REVERSAL -> Known.INTEREST_REVERSAL + INTERNAL_ADJUSTMENT -> Known.INTERNAL_ADJUSTMENT + LATE_PAYMENT -> Known.LATE_PAYMENT + LATE_PAYMENT_REVERSAL -> Known.LATE_PAYMENT_REVERSAL + LOSS_WRITE_OFF -> Known.LOSS_WRITE_OFF + PROVISIONAL_CREDIT -> Known.PROVISIONAL_CREDIT + PROVISIONAL_CREDIT_REVERSAL -> Known.PROVISIONAL_CREDIT_REVERSAL + SERVICE -> Known.SERVICE + RETURN -> Known.RETURN + RETURN_REVERSAL -> Known.RETURN_REVERSAL + TRANSFER -> Known.TRANSFER + TRANSFER_INSUFFICIENT_FUNDS -> Known.TRANSFER_INSUFFICIENT_FUNDS + RETURNED_PAYMENT -> Known.RETURNED_PAYMENT + RETURNED_PAYMENT_REVERSAL -> Known.RETURNED_PAYMENT_REVERSAL + LITHIC_NETWORK_PAYMENT -> Known.LITHIC_NETWORK_PAYMENT + else -> + throw LithicInvalidDataException("Unknown FinancialEventType: $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(): FinancialEventType = 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 other is FinancialEventType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialEvent && + token == other.token && + amount == other.amount && + created == other.created && + result == other.result && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(token, amount, created, result, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FinancialEvent{token=$token, amount=$amount, created=$created, result=$result, type=$type, additionalProperties=$additionalProperties}" + } + + 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 @@ -1699,7 +2387,7 @@ private constructor( return true } - return other is TransactionStatus && value == other.value + return other is TransactionFamilyTypes && value == other.value } override fun hashCode() = value.hashCode() @@ -1707,737 +2395,707 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Transaction result */ + class TransactionResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return 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 - } + /** + * 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 - private val hashCode: Int by lazy { - Objects.hash( - token, - category, - created, - currency, - descriptor, - events, - family, - financialAccountToken, - pendingAmount, - result, - settledAmount, - status, - updated, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val APPROVED = of("APPROVED") - 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}" - } + @JvmField val DECLINED = of("DECLINED") - /** 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, - ) { + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } - @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(), - ) + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - /** - * 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") + /** + * 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, + } - /** - * @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") + /** + * 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 + } - /** - * 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") + /** + * 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") + } - /** - * 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") + /** + * 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") + } - /** - * 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") + private var validated: Boolean = false - /** - * @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") + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } - /** - * 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") + known() + validated = true + } - /** - * 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") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** - * @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") + /** + * 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 - /** - * 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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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") + return other is TransactionResult && value == other.value + } - /** - * 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") + override fun hashCode() = value.hashCode() - /** - * 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") + override fun toString() = value.toString() + } - /** - * 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") + /** The status of the transaction */ + class TransactionStatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * 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 - /** - * @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") + companion object { - /** - * 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 + @JvmField val PENDING = of("PENDING") - /** - * 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 + @JvmField val SETTLED = of("SETTLED") - /** - * 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 + @JvmField val DECLINED = of("DECLINED") - /** - * 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 + @JvmField val REVERSED = of("REVERSED") - /** - * 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 + @JvmField val CANCELED = of("CANCELED") - /** - * 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 + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } - /** - * 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 + /** + * 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 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 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 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 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 a mutable builder for constructing an instance of [BookTransferTransaction]. + * Returns this class instance's primitive wire representation. * - * The following fields are required: - * ```java - * .token() - * .category() - * .created() - * .currency() - * .events() - * .family() - * .fromFinancialAccountToken() - * .pendingAmount() - * .result() - * .settledAmount() - * .status() - * .toFinancialAccountToken() - * .updated() - * ``` + * 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. */ - @JvmStatic fun builder() = Builder() - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - /** A builder for [BookTransferTransaction]. */ - class Builder internal constructor() { + private var validated: Boolean = false - 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() + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } - @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() + known() + validated = true } - /** Unique identifier for the transaction */ - fun token(token: String) = token(JsonField.of(token)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Sets [Builder.token] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun token(token: JsonField) = apply { this.token = token } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun category(category: TransactionCategory) = category(JsonField.of(category)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 + return other is TransactionStatus && value == other.value } - /** 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 } + override fun hashCode() = value.hashCode() - /** Currency of the transaction in ISO 4217 format */ - fun currency(currency: String) = currency(JsonField.of(currency)) + override fun toString() = value.toString() + } - /** - * 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 } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** List of events associated with this book transfer */ - fun events(events: List) = events(JsonField.of(events)) + return 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 + } - /** - * 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() } - } + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + descriptor, + events, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + status, + updated, + additionalProperties, + ) + } - /** - * 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) - } - } + override fun hashCode(): Int = hashCode - fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + 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}" + } - /** - * 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 } + /** 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, + ) { - /** Source account token */ - fun fromFinancialAccountToken(fromFinancialAccountToken: String) = - fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) + @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(), + ) - /** - * 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 - } + /** + * 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") - /** The pending amount of the transaction in cents */ - fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + /** + * @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") - /** - * 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 - } + /** + * 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") - fun result(result: TransactionResult) = result(JsonField.of(result)) + /** + * 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") - /** - * 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 } + /** + * 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") - /** The settled amount of the transaction in cents */ - fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + /** + * @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") - /** - * 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 - } + /** + * 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 status of the transaction */ - fun status(status: TransactionStatus) = status(JsonField.of(status)) + /** + * 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") - /** - * 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 } + /** + * @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") - /** Destination account token */ - fun toFinancialAccountToken(toFinancialAccountToken: String) = - toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + /** + * 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") - /** - * 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 - } + /** + * 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 */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + /** + * 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") - /** - * 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 } + /** + * 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 */ - fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + /** + * 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") - /** - * 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 + * + * @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") - /** External resource associated with the management operation */ - fun externalResource(externalResource: ExternalResource?) = - externalResource(JsonField.ofNullable(externalResource)) + /** + * @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") - /** - * Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. - */ - fun externalResource(externalResource: Optional) = - externalResource(externalResource.getOrNull()) + /** + * 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 - /** - * 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 - } + /** + * 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 - fun transactionSeries(transactionSeries: TransactionSeries?) = - transactionSeries(JsonField.ofNullable(transactionSeries)) + /** + * 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 - /** - * Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. - */ - fun transactionSeries(transactionSeries: Optional) = - transactionSeries(transactionSeries.getOrNull()) + /** + * 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 - /** - * 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 - } + /** + * 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 - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * 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 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * 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 - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * 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 - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * 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 - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * 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 an immutable instance of [BookTransferTransaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of [BookTransferTransaction]. * * The following fields are required: * ```java @@ -2455,450 +3113,409 @@ private constructor( * .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(), - ) + @JvmStatic fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): BookTransferTransaction = apply { - if (validated) { - return@apply - } + /** A builder for [BookTransferTransaction]. */ + class Builder internal constructor() { - 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 - } + 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() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false + @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() } - /** - * 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 { + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) /** - * Returns this class instance's raw value. + * Sets [Builder.token] to an arbitrary JSON 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. + * 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. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun token(token: JsonField) = apply { this.token = token } - companion object { + fun category(category: TransactionCategory) = category(JsonField.of(category)) - @JvmField val ACH = of("ACH") + /** + * 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 + } - @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) - @JvmField val CARD = of("CARD") + /** + * 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 } - @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) - @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + /** + * 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 } - @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + /** List of events associated with this book transfer */ + fun events(events: List) = events(JsonField.of(events)) - @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + /** + * 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() } + } - @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + /** + * Adds a single [BookTransferEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: BookTransferEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } - @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) - @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + /** + * 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 } - @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + /** Source account token */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) - @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + /** + * 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 + } - @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + /** The pending amount of the transaction in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) - @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + /** + * 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 } - /** 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, - } + fun result(result: TransactionResult) = result(JsonField.of(result)) /** - * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] - * member. + * Sets [Builder.result] to an arbitrary JSON value. * - * 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. + * 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. */ - 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, - } + fun result(result: JsonField) = apply { this.result = result } + + /** The settled amount of the transaction in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.settledAmount] to an arbitrary JSON 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. + * 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 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 - } + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: TransactionStatus) = status(JsonField.of(status)) /** - * 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. + * Sets [Builder.status] to an arbitrary JSON value. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * 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 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") - } + fun status(status: JsonField) = apply { this.status = status } + + /** Destination account token */ + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) /** - * 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. + * Sets [Builder.toFinancialAccountToken] to an arbitrary JSON value. * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * 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 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 toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + this.toFinancialAccountToken = toFinancialAccountToken } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.updated] to an arbitrary JSON value. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TransactionCategory && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + fun updated(updated: JsonField) = apply { this.updated = updated } - class TransactionFamilyTypes - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** External identifier for the transaction */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) /** - * Returns this class instance's raw value. + * Sets [Builder.externalId] to an arbitrary JSON 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. + * 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. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } - companion object { + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) - @JvmField val CARD = of("CARD") + /** + * Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. + */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) - @JvmField val PAYMENT = of("PAYMENT") + /** + * 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 + } - @JvmField val TRANSFER = of("TRANSFER") + fun transactionSeries(transactionSeries: TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) - @JvmField val INTERNAL = of("INTERNAL") + /** + * Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. + */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) - @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") + /** + * 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 + } - @JvmField val MANAGEMENT_OPERATION = of("MANAGEMENT_OPERATION") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic fun of(value: String) = TransactionFamilyTypes(JsonField.of(value)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** An enum containing [TransactionFamilyTypes]'s known values. */ - enum class Known { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * 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, + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Returns an immutable instance of [BookTransferTransaction]. * - * 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. + * Further updates to this [Builder] will not mutate the returned instance. * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * ``` * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * @throws IllegalStateException if any required field is unset. */ - 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 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(), + ) + } - fun validate(): TransactionFamilyTypes = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - known() - validated = true + fun validate(): BookTransferTransaction = apply { + if (validated) { + return@apply } - 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 - } + token() + category().validate() + created() + currency() + events().forEach { it.validate() } + family().validate() + fromFinancialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + toFinancialAccountToken() + updated() + externalId() + externalResource().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + validated = true + } - return other is TransactionFamilyTypes && value == other.value + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * 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()?.sumOf { it.validity().toInt() } ?: 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 TransactionResult + class TransactionCategory @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2914,34 +3531,79 @@ private constructor( companion object { - @JvmField val APPROVED = of("APPROVED") + @JvmField val ACH = of("ACH") - @JvmField val DECLINED = of("DECLINED") + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") - @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + @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 [TransactionResult]'s known values. */ + /** An enum containing [TransactionCategory]'s known values. */ enum class Known { - APPROVED, - DECLINED, + 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 [TransactionResult]'s known values, as well as an [_UNKNOWN] + * An enum containing [TransactionCategory]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [TransactionResult] can contain an unknown value in a couple of cases: + * 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 { - APPROVED, - DECLINED, + 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 [TransactionResult] was instantiated with an + * An enum member indicating that [TransactionCategory] was instantiated with an * unknown value. */ _UNKNOWN, @@ -2956,8 +3618,19 @@ private constructor( */ fun value(): Value = when (this) { - APPROVED -> Value.APPROVED - DECLINED -> Value.DECLINED + 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 } @@ -2972,9 +3645,20 @@ private constructor( */ fun known(): Known = when (this) { - APPROVED -> Known.APPROVED - DECLINED -> Known.DECLINED - else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + 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") } /** @@ -2993,7 +3677,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TransactionResult = apply { + fun validate(): TransactionCategory = apply { if (validated) { return@apply } @@ -3023,7 +3707,7 @@ private constructor( return true } - return other is TransactionResult && value == other.value + return other is TransactionCategory && value == other.value } override fun hashCode() = value.hashCode() @@ -3031,224 +3715,185 @@ private constructor( override fun toString() = value.toString() } - /** The status of the transaction */ - class TransactionStatus - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** Book transfer Event */ + class BookTransferEvent + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val detailedResults: JsonField, + private val memo: JsonField, + private val result: JsonField, + private val subtype: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("detailed_results") + @ExcludeMissing + detailedResults: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + ) : this( + token, + amount, + created, + detailedResults, + memo, + result, + subtype, + type, + mutableMapOf(), + ) /** - * Returns this class instance's raw value. + * Globally unique identifier. * - * 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. + * @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). */ - @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") + fun token(): String = token.getRequired("token") - @JvmField val CANCELED = of("CANCELED") + /** + * Amount of the financial event that has been settled in the currency's smallest unit + * (e.g., 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 amount(): Long = amount.getRequired("amount") - @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) - } + /** + * Date and time when the financial event 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") - /** An enum containing [TransactionStatus]'s known values. */ - enum class Known { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - } + /** + * @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 detailedResults(): BookTransferDetailedResults = + detailedResults.getRequired("detailed_results") /** - * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] - * member. + * Memo for the transfer. * - * 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. + * @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). */ - enum class Value { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - /** - * An enum member indicating that [TransactionStatus] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun memo(): String = memo.getRequired("memo") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * @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 value(): Value = - when (this) { - PENDING -> Value.PENDING - SETTLED -> Value.SETTLED - DECLINED -> Value.DECLINED - REVERSED -> Value.REVERSED - CANCELED -> Value.CANCELED - else -> Value._UNKNOWN - } + fun result(): Result = result.getRequired("result") /** - * 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. + * The program specific subtype code for the specified category/type. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * @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 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") - } + fun subtype(): String = subtype.getRequired("subtype") /** - * 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. + * Type of the book transfer * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @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 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 - } + fun type(): BookTransferType = type.getRequired("type") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [token]. * - * Used for best match union deserialization. + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TransactionStatus && value == other.value - } + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - 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()) + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - fun relatedTransactionEventToken(): Optional = - relatedTransactionEventToken.getOptional("related_transaction_event_token") + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Returns the raw JSON value of [detailedResults]. + * + * Unlike [detailedResults], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun relatedTransactionToken(): Optional = - relatedTransactionToken.getOptional("related_transaction_token") + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField = detailedResults /** - * @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). + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. */ - fun type(): String = type.getRequired("type") + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** - * Returns the raw JSON value of [relatedTransactionEventToken]. + * Returns the raw JSON value of [result]. * - * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("related_transaction_event_token") - @ExcludeMissing - fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** - * Returns the raw JSON value of [relatedTransactionToken]. + * Returns the raw JSON value of [subtype]. * - * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("related_transaction_token") - @ExcludeMissing - fun _relatedTransactionToken(): JsonField = relatedTransactionToken + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** * 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 + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3265,87 +3910,153 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * Returns a mutable builder for constructing an instance of [BookTransferEvent]. * * The following fields are required: * ```java - * .relatedTransactionEventToken() - * .relatedTransactionToken() + * .token() + * .amount() + * .created() + * .detailedResults() + * .memo() + * .result() + * .subtype() * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TransactionSeries]. */ + /** A builder for [BookTransferEvent]. */ class Builder internal constructor() { - private var relatedTransactionEventToken: JsonField? = null - private var relatedTransactionToken: JsonField? = null - private var type: JsonField? = null + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var detailedResults: JsonField? = null + private var memo: JsonField? = null + private var result: JsonField? = null + private var subtype: 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() + internal fun from(bookTransferEvent: BookTransferEvent) = apply { + token = bookTransferEvent.token + amount = bookTransferEvent.amount + created = bookTransferEvent.created + detailedResults = bookTransferEvent.detailedResults + memo = bookTransferEvent.memo + result = bookTransferEvent.result + subtype = bookTransferEvent.subtype + type = bookTransferEvent.type + additionalProperties = bookTransferEvent.additionalProperties.toMutableMap() } - fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = - relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) /** - * Alias for calling [Builder.relatedTransactionEventToken] with - * `relatedTransactionEventToken.orElse(null)`. + * 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 relatedTransactionEventToken(relatedTransactionEventToken: Optional) = - relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) + fun token(token: JsonField) = apply { this.token = token } /** - * Sets [Builder.relatedTransactionEventToken] to an arbitrary JSON value. + * Amount of the financial event that has been settled in the currency's smallest + * unit (e.g., cents). + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] 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. + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = - apply { - this.relatedTransactionEventToken = relatedTransactionEventToken - } + fun amount(amount: JsonField) = apply { this.amount = amount } - fun relatedTransactionToken(relatedTransactionToken: String?) = - relatedTransactionToken(JsonField.ofNullable(relatedTransactionToken)) + /** Date and time when the financial event occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** - * Alias for calling [Builder.relatedTransactionToken] with - * `relatedTransactionToken.orElse(null)`. + * 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 relatedTransactionToken(relatedTransactionToken: Optional) = - relatedTransactionToken(relatedTransactionToken.getOrNull()) + fun created(created: JsonField) = apply { this.created = created } + + fun detailedResults(detailedResults: BookTransferDetailedResults) = + detailedResults(JsonField.of(detailedResults)) /** - * Sets [Builder.relatedTransactionToken] to an arbitrary JSON value. + * Sets [Builder.detailedResults] 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. + * You should usually call [Builder.detailedResults] with a well-typed + * [BookTransferDetailedResults] 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 detailedResults(detailedResults: JsonField) = + apply { + this.detailedResults = detailedResults + } - fun type(type: String) = type(JsonField.of(type)) + /** Memo for the transfer. */ + fun memo(memo: String) = memo(JsonField.of(memo)) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets [Builder.memo] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [String] value instead. + * You should usually call [Builder.memo] 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 memo(memo: JsonField) = apply { this.memo = memo } + + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + fun result(result: Result) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] 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 program specific subtype code for the specified category/type. */ + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) + + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + + /** Type of the book transfer */ + fun type(type: BookTransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BookTransferType] 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() @@ -3370,23 +4081,33 @@ private constructor( } /** - * Returns an immutable instance of [TransactionSeries]. + * Returns an immutable instance of [BookTransferEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .relatedTransactionEventToken() - * .relatedTransactionToken() + * .token() + * .amount() + * .created() + * .detailedResults() + * .memo() + * .result() + * .subtype() * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TransactionSeries = - TransactionSeries( - checkRequired("relatedTransactionEventToken", relatedTransactionEventToken), - checkRequired("relatedTransactionToken", relatedTransactionToken), + fun build(): BookTransferEvent = + BookTransferEvent( + checkRequired("token", token), + checkRequired("amount", amount), + checkRequired("created", created), + checkRequired("detailedResults", detailedResults), + checkRequired("memo", memo), + checkRequired("result", result), + checkRequired("subtype", subtype), checkRequired("type", type), additionalProperties.toMutableMap(), ) @@ -3394,14 +4115,19 @@ private constructor( private var validated: Boolean = false - fun validate(): TransactionSeries = apply { + fun validate(): BookTransferEvent = apply { if (validated) { return@apply } - relatedTransactionEventToken() - relatedTransactionToken() - type() + token() + amount() + created() + detailedResults().validate() + memo() + result().validate() + subtype() + type().validate() validated = true } @@ -3421,1759 +4147,1309 @@ private constructor( */ @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) + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (detailedResults.asKnown().getOrNull()?.validity() ?: 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtype.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class BookTransferDetailedResults + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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 FUNDS_INSUFFICIENT = of("FUNDS_INSUFFICIENT") + + @JvmStatic + fun of(value: String) = BookTransferDetailedResults(JsonField.of(value)) } - return other is TransactionSeries && - relatedTransactionEventToken == other.relatedTransactionEventToken && - relatedTransactionToken == other.relatedTransactionToken && - type == other.type && - additionalProperties == other.additionalProperties - } + /** An enum containing [BookTransferDetailedResults]'s known values. */ + enum class Known { + APPROVED, + FUNDS_INSUFFICIENT, + } - private val hashCode: Int by lazy { - Objects.hash( - relatedTransactionEventToken, - relatedTransactionToken, - type, - additionalProperties, - ) - } + /** + * An enum containing [BookTransferDetailedResults]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [BookTransferDetailedResults] 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, + FUNDS_INSUFFICIENT, + /** + * An enum member indicating that [BookTransferDetailedResults] was instantiated + * with an unknown value. + */ + _UNKNOWN, + } - override fun hashCode(): Int = hashCode + /** + * 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 + FUNDS_INSUFFICIENT -> Value.FUNDS_INSUFFICIENT + else -> Value._UNKNOWN + } - override fun toString() = - "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" - } + /** + * 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 + FUNDS_INSUFFICIENT -> Known.FUNDS_INSUFFICIENT + else -> + throw LithicInvalidDataException( + "Unknown BookTransferDetailedResults: $value" + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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(): BookTransferDetailedResults = 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 other is BookTransferDetailedResults && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - return 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 - } + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + class Result @JsonCreator private constructor(private val value: JsonField) : + Enum { - 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, - ) - } + /** + * 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 - override fun hashCode(): Int = hashCode + companion object { - 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}" - } + @JvmField val APPROVED = of("APPROVED") - /** 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, - ) { + @JvmField val DECLINED = of("DECLINED") - @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(), - ) + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } - 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() + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - /** - * 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") + /** + * 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, + } - /** - * 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") + /** + * 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 + } - /** - * 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") + /** + * 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") + } - /** - * 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") + /** + * 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") + } - /** - * 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") + private var validated: Boolean = false - /** - * @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") + fun validate(): Result = apply { + if (validated) { + return@apply + } - /** - * 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") + known() + validated = true + } - /** - * 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") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** - * @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") + /** + * 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 - /** - * 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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @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") + return other is Result && value == other.value + } - /** - * 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") + override fun hashCode() = value.hashCode() - /** - * @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") + override fun toString() = value.toString() + } - /** - * 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") + /** Type of the book transfer */ + class BookTransferType + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * 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 - /** - * 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") + companion object { - /** - * 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") + @JvmField val ATM_WITHDRAWAL = of("ATM_WITHDRAWAL") - /** - * 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") + @JvmField val ATM_DECLINE = of("ATM_DECLINE") - /** - * @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") + @JvmField val INTERNATIONAL_ATM_WITHDRAWAL = of("INTERNATIONAL_ATM_WITHDRAWAL") - /** - * @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") + @JvmField val INACTIVITY = of("INACTIVITY") - /** - * 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") + @JvmField val STATEMENT = of("STATEMENT") - /** - * 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") + @JvmField val MONTHLY = of("MONTHLY") - /** - * @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") + @JvmField val QUARTERLY = of("QUARTERLY") - /** - * 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") + @JvmField val ANNUAL = of("ANNUAL") - /** - * @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") + @JvmField val CUSTOMER_SERVICE = of("CUSTOMER_SERVICE") - /** - * @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") + @JvmField val ACCOUNT_MAINTENANCE = of("ACCOUNT_MAINTENANCE") - /** - * 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 + @JvmField val ACCOUNT_ACTIVATION = of("ACCOUNT_ACTIVATION") - /** - * 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 + @JvmField val ACCOUNT_CLOSURE = of("ACCOUNT_CLOSURE") - /** - * 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 + @JvmField val CARD_REPLACEMENT = of("CARD_REPLACEMENT") - /** - * 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 + @JvmField val CARD_DELIVERY = of("CARD_DELIVERY") - /** - * 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 + @JvmField val CARD_CREATE = of("CARD_CREATE") - /** - * 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 + @JvmField val CURRENCY_CONVERSION = of("CURRENCY_CONVERSION") - /** - * 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 + @JvmField val INTEREST = of("INTEREST") - /** - * 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 + @JvmField val LATE_PAYMENT = of("LATE_PAYMENT") - /** - * 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 + @JvmField val BILL_PAYMENT = of("BILL_PAYMENT") - /** - * 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 + @JvmField val CASH_BACK = of("CASH_BACK") - /** - * 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 + @JvmField val ACCOUNT_TO_ACCOUNT = of("ACCOUNT_TO_ACCOUNT") - /** - * 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 + @JvmField val CARD_TO_CARD = of("CARD_TO_CARD") - /** - * 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 + @JvmField val DISBURSE = of("DISBURSE") - /** - * 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 + @JvmField val BILLING_ERROR = of("BILLING_ERROR") - /** - * 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 + @JvmField val LOSS_WRITE_OFF = of("LOSS_WRITE_OFF") - /** - * 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 + @JvmField val EXPIRED_CARD = of("EXPIRED_CARD") - /** - * 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 + @JvmField val EARLY_DERECOGNITION = of("EARLY_DERECOGNITION") - /** - * 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 + @JvmField val ESCHEATMENT = of("ESCHEATMENT") - /** - * 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 + @JvmField val INACTIVITY_FEE_DOWN = of("INACTIVITY_FEE_DOWN") - /** - * 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 + @JvmField val PROVISIONAL_CREDIT = of("PROVISIONAL_CREDIT") - /** - * 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 + @JvmField val DISPUTE_WON = of("DISPUTE_WON") - /** - * 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 + @JvmField val SERVICE = of("SERVICE") - /** - * 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 + @JvmField val TRANSFER = of("TRANSFER") - /** - * 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 + @JvmStatic fun of(value: String) = BookTransferType(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [BookTransferType]'s known values. */ + enum class Known { + ATM_WITHDRAWAL, + ATM_DECLINE, + INTERNATIONAL_ATM_WITHDRAWAL, + INACTIVITY, + STATEMENT, + MONTHLY, + QUARTERLY, + ANNUAL, + CUSTOMER_SERVICE, + ACCOUNT_MAINTENANCE, + ACCOUNT_ACTIVATION, + ACCOUNT_CLOSURE, + CARD_REPLACEMENT, + CARD_DELIVERY, + CARD_CREATE, + CURRENCY_CONVERSION, + INTEREST, + LATE_PAYMENT, + BILL_PAYMENT, + CASH_BACK, + ACCOUNT_TO_ACCOUNT, + CARD_TO_CARD, + DISBURSE, + BILLING_ERROR, + LOSS_WRITE_OFF, + EXPIRED_CARD, + EARLY_DERECOGNITION, + ESCHEATMENT, + INACTIVITY_FEE_DOWN, + PROVISIONAL_CREDIT, + DISPUTE_WON, + SERVICE, + TRANSFER, + } - /** - * 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 + /** + * An enum containing [BookTransferType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BookTransferType] 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 { + ATM_WITHDRAWAL, + ATM_DECLINE, + INTERNATIONAL_ATM_WITHDRAWAL, + INACTIVITY, + STATEMENT, + MONTHLY, + QUARTERLY, + ANNUAL, + CUSTOMER_SERVICE, + ACCOUNT_MAINTENANCE, + ACCOUNT_ACTIVATION, + ACCOUNT_CLOSURE, + CARD_REPLACEMENT, + CARD_DELIVERY, + CARD_CREATE, + CURRENCY_CONVERSION, + INTEREST, + LATE_PAYMENT, + BILL_PAYMENT, + CASH_BACK, + ACCOUNT_TO_ACCOUNT, + CARD_TO_CARD, + DISBURSE, + BILLING_ERROR, + LOSS_WRITE_OFF, + EXPIRED_CARD, + EARLY_DERECOGNITION, + ESCHEATMENT, + INACTIVITY_FEE_DOWN, + PROVISIONAL_CREDIT, + DISPUTE_WON, + SERVICE, + TRANSFER, + /** + * An enum member indicating that [BookTransferType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * 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) { + ATM_WITHDRAWAL -> Value.ATM_WITHDRAWAL + ATM_DECLINE -> Value.ATM_DECLINE + INTERNATIONAL_ATM_WITHDRAWAL -> Value.INTERNATIONAL_ATM_WITHDRAWAL + INACTIVITY -> Value.INACTIVITY + STATEMENT -> Value.STATEMENT + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + CUSTOMER_SERVICE -> Value.CUSTOMER_SERVICE + ACCOUNT_MAINTENANCE -> Value.ACCOUNT_MAINTENANCE + ACCOUNT_ACTIVATION -> Value.ACCOUNT_ACTIVATION + ACCOUNT_CLOSURE -> Value.ACCOUNT_CLOSURE + CARD_REPLACEMENT -> Value.CARD_REPLACEMENT + CARD_DELIVERY -> Value.CARD_DELIVERY + CARD_CREATE -> Value.CARD_CREATE + CURRENCY_CONVERSION -> Value.CURRENCY_CONVERSION + INTEREST -> Value.INTEREST + LATE_PAYMENT -> Value.LATE_PAYMENT + BILL_PAYMENT -> Value.BILL_PAYMENT + CASH_BACK -> Value.CASH_BACK + ACCOUNT_TO_ACCOUNT -> Value.ACCOUNT_TO_ACCOUNT + CARD_TO_CARD -> Value.CARD_TO_CARD + DISBURSE -> Value.DISBURSE + BILLING_ERROR -> Value.BILLING_ERROR + LOSS_WRITE_OFF -> Value.LOSS_WRITE_OFF + EXPIRED_CARD -> Value.EXPIRED_CARD + EARLY_DERECOGNITION -> Value.EARLY_DERECOGNITION + ESCHEATMENT -> Value.ESCHEATMENT + INACTIVITY_FEE_DOWN -> Value.INACTIVITY_FEE_DOWN + PROVISIONAL_CREDIT -> Value.PROVISIONAL_CREDIT + DISPUTE_WON -> Value.DISPUTE_WON + SERVICE -> Value.SERVICE + TRANSFER -> Value.TRANSFER + else -> Value._UNKNOWN + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * 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) { + ATM_WITHDRAWAL -> Known.ATM_WITHDRAWAL + ATM_DECLINE -> Known.ATM_DECLINE + INTERNATIONAL_ATM_WITHDRAWAL -> Known.INTERNATIONAL_ATM_WITHDRAWAL + INACTIVITY -> Known.INACTIVITY + STATEMENT -> Known.STATEMENT + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + CUSTOMER_SERVICE -> Known.CUSTOMER_SERVICE + ACCOUNT_MAINTENANCE -> Known.ACCOUNT_MAINTENANCE + ACCOUNT_ACTIVATION -> Known.ACCOUNT_ACTIVATION + ACCOUNT_CLOSURE -> Known.ACCOUNT_CLOSURE + CARD_REPLACEMENT -> Known.CARD_REPLACEMENT + CARD_DELIVERY -> Known.CARD_DELIVERY + CARD_CREATE -> Known.CARD_CREATE + CURRENCY_CONVERSION -> Known.CURRENCY_CONVERSION + INTEREST -> Known.INTEREST + LATE_PAYMENT -> Known.LATE_PAYMENT + BILL_PAYMENT -> Known.BILL_PAYMENT + CASH_BACK -> Known.CASH_BACK + ACCOUNT_TO_ACCOUNT -> Known.ACCOUNT_TO_ACCOUNT + CARD_TO_CARD -> Known.CARD_TO_CARD + DISBURSE -> Known.DISBURSE + BILLING_ERROR -> Known.BILLING_ERROR + LOSS_WRITE_OFF -> Known.LOSS_WRITE_OFF + EXPIRED_CARD -> Known.EXPIRED_CARD + EARLY_DERECOGNITION -> Known.EARLY_DERECOGNITION + ESCHEATMENT -> Known.ESCHEATMENT + INACTIVITY_FEE_DOWN -> Known.INACTIVITY_FEE_DOWN + PROVISIONAL_CREDIT -> Known.PROVISIONAL_CREDIT + DISPUTE_WON -> Known.DISPUTE_WON + SERVICE -> Known.SERVICE + TRANSFER -> Known.TRANSFER + else -> throw LithicInvalidDataException("Unknown BookTransferType: $value") + } - fun toBuilder() = Builder().from(this) + /** + * 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") + } - companion object { + private var validated: Boolean = false - /** - * 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() - } + fun validate(): BookTransferType = apply { + if (validated) { + return@apply + } - /** A builder for [CardTransaction]. */ - class Builder internal constructor() { + known() + validated = true + } - 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() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - @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() - } + /** + * 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 - /** Globally unique identifier. */ - fun token(token: String) = token(JsonField.of(token)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 } + return other is BookTransferType && value == other.value + } - /** The token for the account associated with this transaction. */ - fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + override fun hashCode() = value.hashCode() - /** - * 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 + override fun toString() = value.toString() } - /** - * 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)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for [Builder.acquirerFee]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun acquirerFee(acquirerFee: Long) = acquirerFee(acquirerFee as Long?) + return other is BookTransferEvent && + token == other.token && + amount == other.amount && + created == other.created && + detailedResults == other.detailedResults && + memo == other.memo && + result == other.result && + subtype == other.subtype && + type == other.type && + additionalProperties == other.additionalProperties + } - /** Alias for calling [Builder.acquirerFee] with `acquirerFee.orElse(null)`. */ - fun acquirerFee(acquirerFee: Optional) = acquirerFee(acquirerFee.getOrNull()) + private val hashCode: Int by lazy { + Objects.hash( + token, + amount, + created, + detailedResults, + memo, + result, + subtype, + type, + additionalProperties, + ) + } - /** - * 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 } + override fun hashCode(): Int = hashCode - /** - * 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)) + override fun toString() = + "BookTransferEvent{token=$token, amount=$amount, created=$created, detailedResults=$detailedResults, memo=$memo, result=$result, subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [Builder.acquirerReferenceNumber] with - * `acquirerReferenceNumber.orElse(null)`. - */ - @Deprecated("deprecated") - fun acquirerReferenceNumber(acquirerReferenceNumber: Optional) = - acquirerReferenceNumber(acquirerReferenceNumber.getOrNull()) + class TransactionFamilyTypes + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.acquirerReferenceNumber] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - @Deprecated("deprecated") - fun acquirerReferenceNumber(acquirerReferenceNumber: JsonField) = apply { - this.acquirerReferenceNumber = acquirerReferenceNumber - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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)) + companion object { - /** - * 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 } + @JvmField val CARD = of("CARD") - fun amounts(amounts: Transaction.TransactionAmounts) = amounts(JsonField.of(amounts)) + @JvmField val PAYMENT = of("PAYMENT") - /** - * 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 - } + @JvmField val TRANSFER = of("TRANSFER") - /** - * The authorization amount of the transaction in the anticipated settlement currency. - */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: Long?) = - authorizationAmount(JsonField.ofNullable(authorizationAmount)) + @JvmField val INTERNAL = of("INTERNAL") - /** - * Alias for [Builder.authorizationAmount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: Long) = - authorizationAmount(authorizationAmount as Long?) + @JvmField val EXTERNAL_PAYMENT = of("EXTERNAL_PAYMENT") - /** - * Alias for calling [Builder.authorizationAmount] with - * `authorizationAmount.orElse(null)`. - */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: Optional) = - authorizationAmount(authorizationAmount.getOrNull()) + @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, + } /** - * Sets [Builder.authorizationAmount] to an arbitrary JSON value. + * An enum containing [TransactionFamilyTypes]'s known values, as well as an [_UNKNOWN] + * member. * - * 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. + * 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. */ - @Deprecated("deprecated") - fun authorizationAmount(authorizationAmount: JsonField) = apply { - this.authorizationAmount = authorizationAmount + enum class Value { + CARD, + PAYMENT, + TRANSFER, + INTERNAL, + EXTERNAL_PAYMENT, + MANAGEMENT_OPERATION, + /** + * An enum member indicating that [TransactionFamilyTypes] was instantiated with an + * unknown value. + */ + _UNKNOWN, } /** - * A fixed-width 6-digit numeric identifier that can be used to identify a transaction - * with networks. + * 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 authorizationCode(authorizationCode: String?) = - authorizationCode(JsonField.ofNullable(authorizationCode)) + 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 + } /** - * Alias for calling [Builder.authorizationCode] with `authorizationCode.orElse(null)`. + * 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 authorizationCode(authorizationCode: Optional) = - authorizationCode(authorizationCode.getOrNull()) + 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") + } /** - * Sets [Builder.authorizationCode] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * 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. + * 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 authorizationCode(authorizationCode: JsonField) = apply { - this.authorizationCode = authorizationCode - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - fun avs(avs: Transaction.Avs?) = avs(JsonField.ofNullable(avs)) + private var validated: Boolean = false - /** Alias for calling [Builder.avs] with `avs.orElse(null)`. */ - fun avs(avs: Optional) = avs(avs.getOrNull()) + fun validate(): TransactionFamilyTypes = apply { + if (validated) { + return@apply + } - /** - * 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 } + known() + validated = true + } - /** Token for the card used in this transaction. */ - fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Sets [Builder.cardToken] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun cardholderAuthentication( - cardholderAuthentication: Transaction.CardholderAuthentication? - ) = cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [Builder.cardholderAuthentication] with - * `cardholderAuthentication.orElse(null)`. - */ - fun cardholderAuthentication( - cardholderAuthentication: Optional - ) = cardholderAuthentication(cardholderAuthentication.getOrNull()) + return other is TransactionFamilyTypes && value == other.value + } - /** - * 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 } + override fun hashCode() = value.hashCode() - /** Date and time when the transaction first occurred. UTC time zone. */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + override fun toString() = value.toString() + } + + class TransactionResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.created] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - fun created(created: JsonField) = apply { this.created = created } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun merchant(merchant: Transaction.Merchant) = merchant(JsonField.of(merchant)) + companion object { - /** - * 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 - } + @JvmField val APPROVED = of("APPROVED") - /** Analogous to the 'amount', but in the merchant currency. */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: Long?) = - merchantAmount(JsonField.ofNullable(merchantAmount)) + @JvmField val DECLINED = of("DECLINED") - /** - * Alias for [Builder.merchantAmount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } - /** Alias for calling [Builder.merchantAmount] with `merchantAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: Optional) = - merchantAmount(merchantAmount.getOrNull()) + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } /** - * Sets [Builder.merchantAmount] to an arbitrary JSON value. + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. * - * 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. + * 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. */ - @Deprecated("deprecated") - fun merchantAmount(merchantAmount: JsonField) = apply { - this.merchantAmount = merchantAmount + enum class Value { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] was instantiated with an + * unknown value. + */ + _UNKNOWN, } - /** Analogous to the 'authorization_amount', but in the merchant currency. */ - @Deprecated("deprecated") - fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long?) = - merchantAuthorizationAmount(JsonField.ofNullable(merchantAuthorizationAmount)) - /** - * Alias for [Builder.merchantAuthorizationAmount]. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * 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)`. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - @Deprecated("deprecated") - fun merchantAuthorizationAmount(merchantAuthorizationAmount: Optional) = - merchantAuthorizationAmount(merchantAuthorizationAmount.getOrNull()) + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } /** - * Sets [Builder.merchantAuthorizationAmount] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's 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. + * 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. */ - @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)) + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } /** - * Sets [Builder.merchantCurrency] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * 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. + * 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. */ - @Deprecated("deprecated") - fun merchantCurrency(merchantCurrency: JsonField) = apply { - this.merchantCurrency = merchantCurrency - } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - /** - * 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)) + private var validated: Boolean = false - /** Alias for calling [Builder.network] with `network.orElse(null)`. */ - fun network(network: Optional) = network(network.getOrNull()) + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } - /** - * 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 } + known() + validated = true + } - /** - * 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)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Alias for [Builder.networkRiskScore]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun networkRiskScore(networkRiskScore: Long) = - networkRiskScore(networkRiskScore as Long?) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Alias for calling [Builder.networkRiskScore] with `networkRiskScore.orElse(null)`. - */ - fun networkRiskScore(networkRiskScore: Optional) = - networkRiskScore(networkRiskScore.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 + return other is TransactionResult && value == other.value } - fun pos(pos: Transaction.Pos) = pos(JsonField.of(pos)) + override fun hashCode() = value.hashCode() - /** - * 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 } + override fun toString() = value.toString() + } - fun result(result: Transaction.DeclineResult) = result(JsonField.of(result)) + /** The status of the transaction */ + class TransactionStatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.result] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - fun result(result: JsonField) = apply { - this.result = result - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** The settled amount of the transaction in the settlement currency. */ - @Deprecated("deprecated") - fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + companion object { - /** - * 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 - } + @JvmField val PENDING = of("PENDING") - /** Status of the transaction. */ - fun status(status: Transaction.Status) = status(JsonField.of(status)) + @JvmField val SETTLED = of("SETTLED") - /** - * 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 } + @JvmField val DECLINED = of("DECLINED") - fun tokenInfo(tokenInfo: Transaction.TokenInfo?) = - tokenInfo(JsonField.ofNullable(tokenInfo)) + @JvmField val REVERSED = of("REVERSED") - /** Alias for calling [Builder.tokenInfo] with `tokenInfo.orElse(null)`. */ - fun tokenInfo(tokenInfo: Optional) = - tokenInfo(tokenInfo.getOrNull()) + @JvmField val CANCELED = of("CANCELED") - /** - * 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 + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) } - /** Date and time when the transaction last updated. UTC time zone. */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + } /** - * Sets [Builder.updated] to an arbitrary JSON value. + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] + * member. * - * 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. + * 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. */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - fun events(events: List) = events(JsonField.of(events)) + enum class Value { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + /** + * An enum member indicating that [TransactionStatus] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.events] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown 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. + * 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 events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + else -> Value._UNKNOWN + } /** - * Adds a single [Transaction.TransactionEvent] to [events]. + * Returns an enum member corresponding to this class instance's value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * 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 addEvent(event: Transaction.TransactionEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { - checkKnown("events", it).add(event) - } - } - - fun family(family: TransactionFamilyTypes) = family(JsonField.of(family)) + 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") + } /** - * Sets [Builder.family] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * 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. + * 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 family(family: JsonField) = apply { this.family = family } + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + known() + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * 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() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - 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(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): CardTransaction = apply { - if (validated) { - return@apply + return other is TransactionStatus && value == other.value } - 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 + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + class TransactionSeries + private constructor( + private val relatedTransactionEventToken: JsonField, + private val relatedTransactionToken: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * 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 { + @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()) /** - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @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, - } + fun relatedTransactionEventToken(): Optional = + relatedTransactionEventToken.getOptional("related_transaction_event_token") /** - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - enum class Value { - CARD, - PAYMENT, - TRANSFER, - INTERNAL, - EXTERNAL_PAYMENT, - MANAGEMENT_OPERATION, - /** - * An enum member indicating that [TransactionFamilyTypes] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun relatedTransactionToken(): Optional = + relatedTransactionToken.getOptional("related_transaction_token") /** - * 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. + * @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 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 - } + fun type(): String = type.getRequired("type") /** - * 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. + * Returns the raw JSON value of [relatedTransactionEventToken]. * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [relatedTransactionEventToken], this method doesn't throw if the JSON field + * has an unexpected type. */ - 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") - } + @JsonProperty("related_transaction_event_token") + @ExcludeMissing + fun _relatedTransactionEventToken(): JsonField = relatedTransactionEventToken /** - * 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. + * Returns the raw JSON value of [relatedTransactionToken]. * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. + * Unlike [relatedTransactionToken], this method doesn't throw if the JSON field has an + * unexpected 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 - } + @JsonProperty("related_transaction_token") + @ExcludeMissing + fun _relatedTransactionToken(): JsonField = relatedTransactionToken /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [type]. * - * Used for best match union deserialization. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - return other is TransactionFamilyTypes && value == other.value + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - 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 { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * 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 + fun toBuilder() = Builder().from(this) companion object { - @JvmField val PENDING = of("PENDING") - - @JvmField val SETTLED = of("SETTLED") + /** + * Returns a mutable builder for constructing an instance of [TransactionSeries]. + * + * The following fields are required: + * ```java + * .relatedTransactionEventToken() + * .relatedTransactionToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val DECLINED = of("DECLINED") + /** A builder for [TransactionSeries]. */ + class Builder internal constructor() { - @JvmField val REVERSED = of("REVERSED") + private var relatedTransactionEventToken: JsonField? = null + private var relatedTransactionToken: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val CANCELED = of("CANCELED") + @JvmSynthetic + internal fun from(transactionSeries: TransactionSeries) = apply { + relatedTransactionEventToken = transactionSeries.relatedTransactionEventToken + relatedTransactionToken = transactionSeries.relatedTransactionToken + type = transactionSeries.type + additionalProperties = transactionSeries.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) - } + fun relatedTransactionEventToken(relatedTransactionEventToken: String?) = + relatedTransactionEventToken(JsonField.ofNullable(relatedTransactionEventToken)) - /** An enum containing [TransactionStatus]'s known values. */ - enum class Known { - PENDING, - SETTLED, - DECLINED, - REVERSED, - CANCELED, - } + /** + * Alias for calling [Builder.relatedTransactionEventToken] with + * `relatedTransactionEventToken.orElse(null)`. + */ + fun relatedTransactionEventToken(relatedTransactionEventToken: Optional) = + relatedTransactionEventToken(relatedTransactionEventToken.getOrNull()) - /** - * 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. + * 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. */ - _UNKNOWN, - } + fun relatedTransactionEventToken(relatedTransactionEventToken: JsonField) = + apply { + this.relatedTransactionEventToken = relatedTransactionEventToken + } - /** - * 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 + 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 } - /** - * 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") + 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) } - /** - * 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") + 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(): TransactionStatus = apply { + fun validate(): TransactionSeries = apply { if (validated) { return@apply } - known() + relatedTransactionEventToken() + relatedTransactionToken() + type() validated = true } @@ -5191,19 +5467,37 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @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 other is TransactionStatus && value == other.value + return other is TransactionSeries && + relatedTransactionEventToken == other.relatedTransactionEventToken && + relatedTransactionToken == other.relatedTransactionToken && + type == other.type && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + relatedTransactionEventToken, + relatedTransactionToken, + type, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionSeries{relatedTransactionEventToken=$relatedTransactionEventToken, relatedTransactionToken=$relatedTransactionToken, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -5211,64 +5505,44 @@ private constructor( return true } - return other is CardTransaction && + return other is BookTransferTransaction && 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 && + category == other.category && created == other.created && - merchant == other.merchant && - merchantAmount == other.merchantAmount && - merchantAuthorizationAmount == other.merchantAuthorizationAmount && - merchantCurrency == other.merchantCurrency && - network == other.network && - networkRiskScore == other.networkRiskScore && - pos == other.pos && + currency == other.currency && + events == other.events && + family == other.family && + fromFinancialAccountToken == other.fromFinancialAccountToken && + pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && - tokenInfo == other.tokenInfo && + toFinancialAccountToken == other.toFinancialAccountToken && updated == other.updated && - events == other.events && - family == other.family && + externalId == other.externalId && + externalResource == other.externalResource && + transactionSeries == other.transactionSeries && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( token, - accountToken, - acquirerFee, - acquirerReferenceNumber, - amount, - amounts, - authorizationAmount, - authorizationCode, - avs, - cardToken, - cardholderAuthentication, + category, created, - merchant, - merchantAmount, - merchantAuthorizationAmount, - merchantCurrency, - network, - networkRiskScore, - pos, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, result, settledAmount, status, - tokenInfo, + toFinancialAccountToken, updated, - events, - family, + externalId, + externalResource, + transactionSeries, additionalProperties, ) } @@ -5276,122 +5550,175 @@ private constructor( 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}" + "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}" } - /** Payment transaction */ - class PaymentTransaction + /** Base class for all transaction types in the ledger service */ + class CardTransaction 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 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 source: JsonField, - private val status: JsonField, + private val status: JsonField, + private val tokenInfo: JsonField, private val updated: JsonField, - private val currency: JsonField, - private val expectedReleaseDate: JsonField, - private val externalBankAccountToken: JsonField, - private val userDefinedId: JsonField, + private val events: JsonField>, + private val family: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("category") + @JsonProperty("account_token") @ExcludeMissing - category: JsonField = JsonMissing.of(), - @JsonProperty("created") + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_fee") @ExcludeMissing - created: JsonField = JsonMissing.of(), - @JsonProperty("descriptor") + acquirerFee: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_reference_number") @ExcludeMissing - descriptor: JsonField = JsonMissing.of(), - @JsonProperty("direction") + acquirerReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("amounts") @ExcludeMissing - direction: JsonField = JsonMissing.of(), - @JsonProperty("events") + amounts: JsonField = JsonMissing.of(), + @JsonProperty("authorization_amount") @ExcludeMissing - events: JsonField> = JsonMissing.of(), - @JsonProperty("family") + authorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("authorization_code") @ExcludeMissing - family: JsonField = JsonMissing.of(), - @JsonProperty("financial_account_token") + authorizationCode: JsonField = JsonMissing.of(), + @JsonProperty("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing - financialAccountToken: JsonField = JsonMissing.of(), - @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), - @JsonProperty("method_attributes") + cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_authentication") @ExcludeMissing - methodAttributes: JsonField = JsonMissing.of(), - @JsonProperty("pending_amount") + cardholderAuthentication: JsonField = + JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing - pendingAmount: JsonField = JsonMissing.of(), - @JsonProperty("related_account_tokens") + created: JsonField = JsonMissing.of(), + @JsonProperty("merchant") @ExcludeMissing - relatedAccountTokens: JsonField = JsonMissing.of(), + 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(), + 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(), + status: JsonField = JsonMissing.of(), + @JsonProperty("token_info") + @ExcludeMissing + tokenInfo: 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") + @JsonProperty("events") @ExcludeMissing - externalBankAccountToken: JsonField = JsonMissing.of(), - @JsonProperty("user_defined_id") + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") @ExcludeMissing - userDefinedId: JsonField = JsonMissing.of(), + family: JsonField = JsonMissing.of(), ) : this( token, - category, + accountToken, + acquirerFee, + acquirerReferenceNumber, + amount, + amounts, + authorizationAmount, + authorizationCode, + avs, + cardToken, + cardholderAuthentication, created, - descriptor, - direction, - events, - family, - financialAccountToken, - method, - methodAttributes, - pendingAmount, - relatedAccountTokens, + merchant, + merchantAmount, + merchantAuthorizationAmount, + merchantCurrency, + network, + networkRiskScore, + pos, result, settledAmount, - source, status, + tokenInfo, updated, - currency, - expectedReleaseDate, - externalBankAccountToken, - userDefinedId, + 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() + /** - * Unique identifier for the transaction + * 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). @@ -5399,1229 +5726,3888 @@ private constructor( fun token(): String = token.getRequired("token") /** - * Transaction category + * 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 category(): TransactionCategory = category.getRequired("category") + fun accountToken(): String = accountToken.getRequired("account_token") /** - * ISO 8601 timestamp of when the transaction was created + * 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). */ - fun created(): OffsetDateTime = created.getRequired("created") + @Deprecated("deprecated") fun amount(): Long = amount.getRequired("amount") /** - * 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 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 descriptor(): String = descriptor.getRequired("descriptor") + 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 other is TransactionFamilyTypes && value == other.value + } + + 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 other is TransactionStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is 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 + } + + 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, + ) + } + + 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 [PaymentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: PaymentEvent) = 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)) - /** - * 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") + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) - /** - * 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") + /** + * 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 + } - /** - * @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") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * 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") + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * 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") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * 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") + /** + * 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(), + ) + } - /** - * 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") + private var validated: Boolean = false - /** - * 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") + fun validate(): PaymentTransaction = apply { + if (validated) { + return@apply + } - /** - * 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") + token() + category().validate() + created() + descriptor() + direction().validate() + events().forEach { it.validate() } + family().validate() + financialAccountToken() + method().validate() + methodAttributes().validate() + pendingAmount() + relatedAccountTokens().validate() + result().validate() + settledAmount() + source().validate() + status().validate() + updated() + currency() + expectedReleaseDate() + externalBankAccountToken() + userDefinedId() + validated = true + } - /** - * 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") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * ISO 8601 timestamp of when the transaction was last updated + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @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). + * Used for best match union deserialization. */ - fun updated(): OffsetDateTime = updated.getRequired("updated") + @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()?.sumOf { it.validity().toInt() } ?: 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) - /** - * 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") + /** Transaction category */ + class TransactionCategory + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * 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 - /** - * 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") + companion object { - /** - * 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") + @JvmField val ACH = of("ACH") - /** - * 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 + @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") - /** - * 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 + @JvmField val CARD = of("CARD") - /** - * 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 + @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") - /** - * 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 + @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") - /** - * 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 + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") - /** - * 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 + @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") - /** - * 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 + @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") - /** - * 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 + @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") - /** - * 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 + @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") - /** - * 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 + @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") - /** - * 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 + @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") - /** - * 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 + @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") - /** - * 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 + @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) + } - /** - * 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 + /** 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, + } - /** - * 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 + /** + * 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") + } - /** - * 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 + private var validated: Boolean = false - /** - * 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 + fun validate(): TransactionCategory = apply { + if (validated) { + return@apply + } - /** - * 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 + known() + validated = true + } - /** - * 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 + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** - * 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 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 - /** - * 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is TransactionCategory && value == other.value + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode() = value.hashCode() - fun toBuilder() = Builder().from(this) + override fun toString() = value.toString() + } - companion object { + /** Transfer direction */ + class Direction @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns a mutable builder for constructing an instance of [PaymentTransaction]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .token() - * .category() - * .created() - * .descriptor() - * .direction() - * .events() - * .family() - * .financialAccountToken() - * .method() - * .methodAttributes() - * .pendingAmount() - * .relatedAccountTokens() - * .result() - * .settledAmount() - * .source() - * .status() - * .updated() - * ``` + * 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. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [PaymentTransaction]. */ - class Builder internal constructor() { + companion object { - 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() + @JvmField val CREDIT = of("CREDIT") - @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() + @JvmField val DEBIT = of("DEBIT") + + @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) } - /** Unique identifier for the transaction */ - fun token(token: String) = token(JsonField.of(token)) + /** An enum containing [Direction]'s known values. */ + enum class Known { + CREDIT, + DEBIT, + } /** - * Sets [Builder.token] to an arbitrary JSON value. + * An enum containing [Direction]'s known values, as well as an [_UNKNOWN] member. * - * 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. + * 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. */ - fun token(token: JsonField) = apply { this.token = token } + enum class Value { + CREDIT, + DEBIT, + /** + * An enum member indicating that [Direction] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** Transaction category */ - fun category(category: TransactionCategory) = category(JsonField.of(category)) + /** + * 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 + } /** - * Sets [Builder.category] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun category(category: JsonField) = apply { - this.category = category + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Direction && value == other.value } - /** ISO 8601 timestamp of when the transaction was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + override fun hashCode() = value.hashCode() - /** - * 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 } + override fun toString() = value.toString() + } - /** Transaction descriptor */ - fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + /** Payment Event */ + class PaymentEvent + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val result: JsonField, + private val type: JsonField, + private val detailedResults: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("detailed_results") + @ExcludeMissing + detailedResults: JsonField> = JsonMissing.of(), + ) : this(token, amount, created, result, type, detailedResults, mutableMapOf()) /** - * Sets [Builder.descriptor] to an arbitrary JSON value. + * Globally unique identifier. * - * 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. + * @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(descriptor: JsonField) = apply { this.descriptor = descriptor } - - /** Transfer direction */ - fun direction(direction: Direction) = direction(JsonField.of(direction)) + fun token(): String = token.getRequired("token") /** - * Sets [Builder.direction] to an arbitrary JSON value. + * Amount of the financial event that has been settled in the currency's smallest unit + * (e.g., cents). * - * 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. + * @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: JsonField) = apply { this.direction = direction } - - /** List of transaction events */ - fun events(events: List) = events(JsonField.of(events)) + fun amount(): Long = amount.getRequired("amount") /** - * Sets [Builder.events] to an arbitrary JSON value. + * Date and time when the financial event occurred. UTC time zone. * - * 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. + * @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(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun created(): OffsetDateTime = created.getRequired("created") /** - * Adds a single [JsonValue] to [events]. + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @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 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. + fun result(): Result = result.getRequired("result") + + /** + * Event types: + * - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending approval/release + * from an ACH hold. + * - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process. + * - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled. + * - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to the + * Federal Reserve. + * - `ACH_ORIGINATION_SETTLED` - ACH origination has settled. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository + * Financial Institution. + * - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder. + * - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt. + * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository + * Financial Institution. * - * 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. + * @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(family: JsonField) = apply { this.family = family } - - /** Financial account token */ - fun financialAccountToken(financialAccountToken: String) = - financialAccountToken(JsonField.of(financialAccountToken)) + fun type(): Type = type.getRequired("type") /** - * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * More detailed reasons for the event * - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - fun financialAccountToken(financialAccountToken: JsonField) = apply { - this.financialAccountToken = financialAccountToken - } - - /** Transfer method */ - fun method(method: Method) = method(JsonField.of(method)) + fun detailedResults(): Optional> = + detailedResults.getOptional("detailed_results") /** - * Sets [Builder.method] to an arbitrary JSON value. + * Returns the raw JSON value of [token]. * - * 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. + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. */ - fun method(method: JsonField) = apply { this.method = method } - - /** Method-specific attributes */ - fun methodAttributes(methodAttributes: MethodAttributes) = - methodAttributes(JsonField.of(methodAttributes)) + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** - * Sets [Builder.methodAttributes] to an arbitrary JSON value. + * Returns the raw JSON value of [amount]. * - * 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. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - 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)) + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * Returns the raw JSON value of [created]. * - * 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. + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - fun pendingAmount(pendingAmount: JsonField) = apply { - this.pendingAmount = pendingAmount - } - - /** Related account tokens for the transaction */ - fun relatedAccountTokens(relatedAccountTokens: RelatedAccountTokens) = - relatedAccountTokens(JsonField.of(relatedAccountTokens)) + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * Returns the raw JSON value of [result]. * - * 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. + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. */ - fun relatedAccountTokens(relatedAccountTokens: JsonField) = - apply { - this.relatedAccountTokens = relatedAccountTokens - } - - /** Transaction result */ - fun result(result: TransactionResult) = result(JsonField.of(result)) + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** - * Sets [Builder.result] to an arbitrary JSON value. + * Returns the raw JSON value of [type]. * - * 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. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun result(result: JsonField) = apply { this.result = result } - - /** Settled amount in cents */ - fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** - * Sets [Builder.settledAmount] to an arbitrary JSON value. + * Returns the raw JSON value of [detailedResults]. * - * 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. + * Unlike [detailedResults], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun settledAmount(settledAmount: JsonField) = apply { - this.settledAmount = settledAmount + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** Transaction source */ - fun source(source: Source) = source(JsonField.of(source)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * 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 } + fun toBuilder() = Builder().from(this) - /** The status of the transaction */ - fun status(status: TransactionStatus) = status(JsonField.of(status)) + companion object { - /** - * 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 } + /** + * Returns a mutable builder for constructing an instance of [PaymentEvent]. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .created() + * .result() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** ISO 8601 timestamp of when the transaction was last updated */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + /** A builder for [PaymentEvent]. */ + class Builder internal constructor() { - /** - * 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 } + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var result: JsonField? = null + private var type: JsonField? = null + private var detailedResults: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** Currency of the transaction in ISO 4217 format */ - fun currency(currency: String) = currency(JsonField.of(currency)) + @JvmSynthetic + internal fun from(paymentEvent: PaymentEvent) = apply { + token = paymentEvent.token + amount = paymentEvent.amount + created = paymentEvent.created + result = paymentEvent.result + type = paymentEvent.type + detailedResults = paymentEvent.detailedResults.map { it.toMutableList() } + additionalProperties = paymentEvent.additionalProperties.toMutableMap() + } - /** - * 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 } + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) - /** Expected release date for the transaction */ - fun expectedReleaseDate(expectedReleaseDate: LocalDate?) = - expectedReleaseDate(JsonField.ofNullable(expectedReleaseDate)) + /** + * 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 } + + /** + * Amount of the financial event that has been settled in the currency's smallest + * unit (e.g., cents). + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) - /** - * Alias for calling [Builder.expectedReleaseDate] with - * `expectedReleaseDate.orElse(null)`. - */ - fun expectedReleaseDate(expectedReleaseDate: Optional) = - expectedReleaseDate(expectedReleaseDate.getOrNull()) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - /** - * 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 - } + /** Date and time when the financial event occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) - /** External bank account token */ - fun externalBankAccountToken(externalBankAccountToken: String?) = - externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) + /** + * 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 } - /** - * Alias for calling [Builder.externalBankAccountToken] with - * `externalBankAccountToken.orElse(null)`. - */ - fun externalBankAccountToken(externalBankAccountToken: Optional) = - externalBankAccountToken(externalBankAccountToken.getOrNull()) + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + fun result(result: Result) = result(JsonField.of(result)) - /** - * 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 - } + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] 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 } - /** User-defined identifier */ - fun userDefinedId(userDefinedId: String?) = - userDefinedId(JsonField.ofNullable(userDefinedId)) + /** + * Event types: + * - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending + * approval/release from an ACH hold. + * - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process. + * - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled. + * - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to + * the Federal Reserve. + * - `ACH_ORIGINATION_SETTLED` - ACH origination has settled. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository + * Financial Institution. + * - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder. + * - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt. + * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available + * balance. + * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository + * Financial Institution. + */ + fun type(type: Type) = type(JsonField.of(type)) - /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ - fun userDefinedId(userDefinedId: Optional) = - userDefinedId(userDefinedId.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } - /** - * 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 - } + /** More detailed reasons for the event */ + fun detailedResults(detailedResults: List) = + detailedResults(JsonField.of(detailedResults)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.detailedResults] to an arbitrary JSON value. + * + * You should usually call [Builder.detailedResults] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun detailedResults(detailedResults: JsonField>) = apply { + this.detailedResults = detailedResults.map { it.toMutableList() } + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Adds a single [DetailedResult] to [detailedResults]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDetailedResult(detailedResult: DetailedResult) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).also { + checkKnown("detailedResults", it).add(detailedResult) + } + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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(), - ) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): PaymentTransaction = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [PaymentEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .created() + * .result() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentEvent = + PaymentEvent( + checkRequired("token", token), + checkRequired("amount", amount), + checkRequired("created", created), + checkRequired("result", result), + checkRequired("type", type), + (detailedResults ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - 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 - } + private var validated: Boolean = false - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + fun validate(): PaymentEvent = apply { + if (validated) { + return@apply + } - /** - * 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) + token() + amount() + created() + result().validate() + type().validate() + detailedResults().ifPresent { it.forEach { it.validate() } } + validated = true + } - /** Transaction category */ - class TransactionCategory - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } /** - * Returns this class instance's raw value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (detailedResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - companion object { + /** + * APPROVED financial events were successful while DECLINED financial events were + * declined by user, Lithic, or the network. + */ + class Result @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmField val ACH = of("ACH") + /** + * 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 - @JvmField val BALANCE_OR_FUNDING = of("BALANCE_OR_FUNDING") + companion object { - @JvmField val CARD = of("CARD") + @JvmField val APPROVED = of("APPROVED") - @JvmField val EXTERNAL_ACH = of("EXTERNAL_ACH") + @JvmField val DECLINED = of("DECLINED") - @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } - @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } - @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") + /** + * 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, + } - @JvmField val MANAGEMENT_ADJUSTMENT = of("MANAGEMENT_ADJUSTMENT") + /** + * 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 + } - @JvmField val MANAGEMENT_DISPUTE = of("MANAGEMENT_DISPUTE") + /** + * 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") + } - @JvmField val MANAGEMENT_FEE = of("MANAGEMENT_FEE") + /** + * 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") + } - @JvmField val MANAGEMENT_REWARD = of("MANAGEMENT_REWARD") + private var validated: Boolean = false - @JvmField val MANAGEMENT_DISBURSEMENT = of("MANAGEMENT_DISBURSEMENT") + fun validate(): Result = apply { + if (validated) { + return@apply + } - @JvmField val PROGRAM_FUNDING = of("PROGRAM_FUNDING") + known() + validated = true + } - @JvmStatic fun of(value: String) = TransactionCategory(JsonField.of(value)) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - /** 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, + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** - * 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. + * Event types: + * - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending approval/release + * from an ACH hold. + * - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process. + * - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled. + * - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to the + * Federal Reserve. + * - `ACH_ORIGINATION_SETTLED` - ACH origination has settled. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository + * Financial Institution. + * - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder. + * - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt. + * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository + * Financial Institution. */ - 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, + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + /** - * An enum member indicating that [TransactionCategory] was instantiated with an - * unknown value. + * 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. */ - _UNKNOWN, - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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 + companion object { + + @JvmField val ACH_ORIGINATION_CANCELLED = of("ACH_ORIGINATION_CANCELLED") + + @JvmField val ACH_ORIGINATION_INITIATED = of("ACH_ORIGINATION_INITIATED") + + @JvmField val ACH_ORIGINATION_PROCESSED = of("ACH_ORIGINATION_PROCESSED") + + @JvmField val ACH_ORIGINATION_SETTLED = of("ACH_ORIGINATION_SETTLED") + + @JvmField val ACH_ORIGINATION_RELEASED = of("ACH_ORIGINATION_RELEASED") + + @JvmField val ACH_ORIGINATION_REVIEWED = of("ACH_ORIGINATION_REVIEWED") + + @JvmField val ACH_RECEIPT_PROCESSED = of("ACH_RECEIPT_PROCESSED") + + @JvmField val ACH_RECEIPT_SETTLED = of("ACH_RECEIPT_SETTLED") + + @JvmField val ACH_RETURN_INITIATED = of("ACH_RETURN_INITIATED") + + @JvmField val ACH_RETURN_PROCESSED = of("ACH_RETURN_PROCESSED") + + @JvmField val ACH_RETURN_SETTLED = of("ACH_RETURN_SETTLED") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - /** - * 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") + /** An enum containing [Type]'s known values. */ + enum class Known { + ACH_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_SETTLED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, } - /** - * 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") + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACH_ORIGINATION_CANCELLED, + ACH_ORIGINATION_INITIATED, + ACH_ORIGINATION_PROCESSED, + ACH_ORIGINATION_SETTLED, + ACH_ORIGINATION_RELEASED, + ACH_ORIGINATION_REVIEWED, + ACH_RECEIPT_PROCESSED, + ACH_RECEIPT_SETTLED, + ACH_RETURN_INITIATED, + ACH_RETURN_PROCESSED, + ACH_RETURN_SETTLED, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, } - private var validated: Boolean = false + /** + * 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_ORIGINATION_CANCELLED -> Value.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Value.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Value.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_SETTLED -> Value.ACH_ORIGINATION_SETTLED + ACH_ORIGINATION_RELEASED -> Value.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Value.ACH_ORIGINATION_REVIEWED + ACH_RECEIPT_PROCESSED -> Value.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Value.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Value.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Value.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Value.ACH_RETURN_SETTLED + 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_ORIGINATION_CANCELLED -> Known.ACH_ORIGINATION_CANCELLED + ACH_ORIGINATION_INITIATED -> Known.ACH_ORIGINATION_INITIATED + ACH_ORIGINATION_PROCESSED -> Known.ACH_ORIGINATION_PROCESSED + ACH_ORIGINATION_SETTLED -> Known.ACH_ORIGINATION_SETTLED + ACH_ORIGINATION_RELEASED -> Known.ACH_ORIGINATION_RELEASED + ACH_ORIGINATION_REVIEWED -> Known.ACH_ORIGINATION_REVIEWED + ACH_RECEIPT_PROCESSED -> Known.ACH_RECEIPT_PROCESSED + ACH_RECEIPT_SETTLED -> Known.ACH_RECEIPT_SETTLED + ACH_RETURN_INITIATED -> Known.ACH_RETURN_INITIATED + ACH_RETURN_PROCESSED -> Known.ACH_RETURN_PROCESSED + ACH_RETURN_SETTLED -> Known.ACH_RETURN_SETTLED + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 + } - fun validate(): TransactionCategory = apply { - if (validated) { - return@apply + return other is Type && value == other.value } - known() - validated = true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } + class DetailedResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * 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 + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is TransactionCategory && value == other.value - } + @JvmField val APPROVED = of("APPROVED") - override fun hashCode() = value.hashCode() + @JvmField val FUNDS_INSUFFICIENT = of("FUNDS_INSUFFICIENT") - override fun toString() = value.toString() - } + @JvmField val ACCOUNT_INVALID = of("ACCOUNT_INVALID") - /** Transfer direction */ - class Direction @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JvmField + val PROGRAM_TRANSACTION_LIMIT_EXCEEDED = + of("PROGRAM_TRANSACTION_LIMIT_EXCEEDED") - /** - * 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 + @JvmField val PROGRAM_DAILY_LIMIT_EXCEEDED = of("PROGRAM_DAILY_LIMIT_EXCEEDED") - companion object { + @JvmField + val PROGRAM_MONTHLY_LIMIT_EXCEEDED = of("PROGRAM_MONTHLY_LIMIT_EXCEEDED") - @JvmField val CREDIT = of("CREDIT") + @JvmStatic fun of(value: String) = DetailedResult(JsonField.of(value)) + } - @JvmField val DEBIT = of("DEBIT") + /** An enum containing [DetailedResult]'s known values. */ + enum class Known { + APPROVED, + FUNDS_INSUFFICIENT, + ACCOUNT_INVALID, + PROGRAM_TRANSACTION_LIMIT_EXCEEDED, + PROGRAM_DAILY_LIMIT_EXCEEDED, + PROGRAM_MONTHLY_LIMIT_EXCEEDED, + } - @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) - } + /** + * An enum containing [DetailedResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DetailedResult] 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, + FUNDS_INSUFFICIENT, + ACCOUNT_INVALID, + PROGRAM_TRANSACTION_LIMIT_EXCEEDED, + PROGRAM_DAILY_LIMIT_EXCEEDED, + PROGRAM_MONTHLY_LIMIT_EXCEEDED, + /** + * An enum member indicating that [DetailedResult] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - /** An enum containing [Direction]'s known values. */ - enum class Known { - CREDIT, - DEBIT, - } + /** + * 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 + FUNDS_INSUFFICIENT -> Value.FUNDS_INSUFFICIENT + ACCOUNT_INVALID -> Value.ACCOUNT_INVALID + PROGRAM_TRANSACTION_LIMIT_EXCEEDED -> + Value.PROGRAM_TRANSACTION_LIMIT_EXCEEDED + PROGRAM_DAILY_LIMIT_EXCEEDED -> Value.PROGRAM_DAILY_LIMIT_EXCEEDED + PROGRAM_MONTHLY_LIMIT_EXCEEDED -> Value.PROGRAM_MONTHLY_LIMIT_EXCEEDED + else -> Value._UNKNOWN + } - /** - * 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. + * 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. */ - _UNKNOWN, - } + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + FUNDS_INSUFFICIENT -> Known.FUNDS_INSUFFICIENT + ACCOUNT_INVALID -> Known.ACCOUNT_INVALID + PROGRAM_TRANSACTION_LIMIT_EXCEEDED -> + Known.PROGRAM_TRANSACTION_LIMIT_EXCEEDED + PROGRAM_DAILY_LIMIT_EXCEEDED -> Known.PROGRAM_DAILY_LIMIT_EXCEEDED + PROGRAM_MONTHLY_LIMIT_EXCEEDED -> Known.PROGRAM_MONTHLY_LIMIT_EXCEEDED + else -> throw LithicInvalidDataException("Unknown DetailedResult: $value") + } - /** - * 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 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") + } - /** - * 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") - } + private var validated: Boolean = false - /** - * 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") + fun validate(): DetailedResult = apply { + if (validated) { + return@apply + } + + known() + validated = true } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } - fun validate(): Direction = apply { - if (validated) { - return@apply - } + /** + * 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 - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false + return other is DetailedResult && value == other.value } - /** - * 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 hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Direction && value == other.value + return other is PaymentEvent && + token == other.token && + amount == other.amount && + created == other.created && + result == other.result && + type == other.type && + detailedResults == other.detailedResults && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + token, + amount, + created, + result, + type, + detailedResults, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentEvent{token=$token, amount=$amount, created=$created, result=$result, type=$type, detailedResults=$detailedResults, additionalProperties=$additionalProperties}" } class TransactionFamilyTypes @@ -7742,10 +10728,13 @@ private constructor( private val externalBankName: JsonField, private val externalBankRoutingNumber: JsonField, private val externalIndividualName: JsonField, + private val imad: JsonField, private val lithicBankName: JsonField, private val lithicBankRoutingNumber: JsonField, private val lithicIndividualName: JsonField, + private val omad: JsonField, private val previousTransfer: JsonField, + private val wireToken: JsonField, private val additionalProperties: MutableMap, ) { @@ -7763,6 +10752,9 @@ private constructor( @JsonProperty("external_individual_name") @ExcludeMissing externalIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("imad") + @ExcludeMissing + imad: JsonField = JsonMissing.of(), @JsonProperty("lithic_bank_name") @ExcludeMissing lithicBankName: JsonField = JsonMissing.of(), @@ -7772,18 +10764,27 @@ private constructor( @JsonProperty("lithic_individual_name") @ExcludeMissing lithicIndividualName: JsonField = JsonMissing.of(), + @JsonProperty("omad") + @ExcludeMissing + omad: JsonField = JsonMissing.of(), @JsonProperty("previous_transfer") @ExcludeMissing previousTransfer: JsonField = JsonMissing.of(), + @JsonProperty("wire_token") + @ExcludeMissing + wireToken: JsonField = JsonMissing.of(), ) : this( wireTransferType, externalBankName, externalBankRoutingNumber, externalIndividualName, + imad, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, + omad, previousTransfer, + wireToken, mutableMapOf(), ) @@ -7824,6 +10825,14 @@ private constructor( fun externalIndividualName(): Optional = externalIndividualName.getOptional("external_individual_name") + /** + * IMAD + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun imad(): Optional = imad.getOptional("imad") + /** * Lithic bank name * @@ -7851,6 +10860,14 @@ private constructor( fun lithicIndividualName(): Optional = lithicIndividualName.getOptional("lithic_individual_name") + /** + * OMAD + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun omad(): Optional = omad.getOptional("omad") + /** * UUID of previous transfer if this is a retry * @@ -7860,6 +10877,14 @@ private constructor( fun previousTransfer(): Optional = previousTransfer.getOptional("previous_transfer") + /** + * Wire token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun wireToken(): Optional = wireToken.getOptional("wire_token") + /** * Returns the raw JSON value of [wireTransferType]. * @@ -7900,6 +10925,14 @@ private constructor( @ExcludeMissing fun _externalIndividualName(): JsonField = externalIndividualName + /** + * Returns the raw JSON value of [imad]. + * + * Unlike [imad], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("imad") @ExcludeMissing fun _imad(): JsonField = imad + /** * Returns the raw JSON value of [lithicBankName]. * @@ -7930,6 +10963,14 @@ private constructor( @ExcludeMissing fun _lithicIndividualName(): JsonField = lithicIndividualName + /** + * Returns the raw JSON value of [omad]. + * + * Unlike [omad], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("omad") @ExcludeMissing fun _omad(): JsonField = omad + /** * Returns the raw JSON value of [previousTransfer]. * @@ -7940,6 +10981,16 @@ private constructor( @ExcludeMissing fun _previousTransfer(): JsonField = previousTransfer + /** + * Returns the raw JSON value of [wireToken]. + * + * Unlike [wireToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wire_token") + @ExcludeMissing + fun _wireToken(): JsonField = wireToken + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7973,10 +11024,13 @@ private constructor( private var externalBankName: JsonField = JsonMissing.of() private var externalBankRoutingNumber: JsonField = JsonMissing.of() private var externalIndividualName: JsonField = JsonMissing.of() + private var imad: JsonField = JsonMissing.of() private var lithicBankName: JsonField = JsonMissing.of() private var lithicBankRoutingNumber: JsonField = JsonMissing.of() private var lithicIndividualName: JsonField = JsonMissing.of() + private var omad: JsonField = JsonMissing.of() private var previousTransfer: JsonField = JsonMissing.of() + private var wireToken: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7985,10 +11039,13 @@ private constructor( externalBankName = wireMethodAttributes.externalBankName externalBankRoutingNumber = wireMethodAttributes.externalBankRoutingNumber externalIndividualName = wireMethodAttributes.externalIndividualName + imad = wireMethodAttributes.imad lithicBankName = wireMethodAttributes.lithicBankName lithicBankRoutingNumber = wireMethodAttributes.lithicBankRoutingNumber lithicIndividualName = wireMethodAttributes.lithicIndividualName + omad = wireMethodAttributes.omad previousTransfer = wireMethodAttributes.previousTransfer + wireToken = wireMethodAttributes.wireToken additionalProperties = wireMethodAttributes.additionalProperties.toMutableMap() } @@ -8075,6 +11132,21 @@ private constructor( this.externalIndividualName = externalIndividualName } + /** IMAD */ + fun imad(imad: String?) = imad(JsonField.ofNullable(imad)) + + /** Alias for calling [Builder.imad] with `imad.orElse(null)`. */ + fun imad(imad: Optional) = imad(imad.getOrNull()) + + /** + * Sets [Builder.imad] to an arbitrary JSON value. + * + * You should usually call [Builder.imad] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imad(imad: JsonField) = apply { this.imad = imad } + /** Lithic bank name */ fun lithicBankName(lithicBankName: String?) = lithicBankName(JsonField.ofNullable(lithicBankName)) @@ -8142,6 +11214,21 @@ private constructor( this.lithicIndividualName = lithicIndividualName } + /** OMAD */ + fun omad(omad: String?) = omad(JsonField.ofNullable(omad)) + + /** Alias for calling [Builder.omad] with `omad.orElse(null)`. */ + fun omad(omad: Optional) = omad(omad.getOrNull()) + + /** + * Sets [Builder.omad] to an arbitrary JSON value. + * + * You should usually call [Builder.omad] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun omad(omad: JsonField) = apply { this.omad = omad } + /** UUID of previous transfer if this is a retry */ fun previousTransfer(previousTransfer: String?) = previousTransfer(JsonField.ofNullable(previousTransfer)) @@ -8164,6 +11251,23 @@ private constructor( this.previousTransfer = previousTransfer } + /** Wire token */ + fun wireToken(wireToken: String?) = wireToken(JsonField.ofNullable(wireToken)) + + /** Alias for calling [Builder.wireToken] with `wireToken.orElse(null)`. */ + fun wireToken(wireToken: Optional) = wireToken(wireToken.getOrNull()) + + /** + * Sets [Builder.wireToken] to an arbitrary JSON value. + * + * You should usually call [Builder.wireToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun wireToken(wireToken: JsonField) = apply { + this.wireToken = wireToken + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8204,10 +11308,13 @@ private constructor( externalBankName, externalBankRoutingNumber, externalIndividualName, + imad, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, + omad, previousTransfer, + wireToken, additionalProperties.toMutableMap(), ) } @@ -8223,10 +11330,13 @@ private constructor( externalBankName() externalBankRoutingNumber() externalIndividualName() + imad() lithicBankName() lithicBankRoutingNumber() lithicIndividualName() + omad() previousTransfer() + wireToken() validated = true } @@ -8250,10 +11360,13 @@ private constructor( (if (externalBankName.asKnown().isPresent) 1 else 0) + (if (externalBankRoutingNumber.asKnown().isPresent) 1 else 0) + (if (externalIndividualName.asKnown().isPresent) 1 else 0) + + (if (imad.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) + (if (omad.asKnown().isPresent) 1 else 0) + + (if (previousTransfer.asKnown().isPresent) 1 else 0) + + (if (wireToken.asKnown().isPresent) 1 else 0) /** Type of wire transfer */ class WireTransferType @@ -8403,10 +11516,13 @@ private constructor( externalBankName == other.externalBankName && externalBankRoutingNumber == other.externalBankRoutingNumber && externalIndividualName == other.externalIndividualName && + imad == other.imad && lithicBankName == other.lithicBankName && lithicBankRoutingNumber == other.lithicBankRoutingNumber && lithicIndividualName == other.lithicIndividualName && + omad == other.omad && previousTransfer == other.previousTransfer && + wireToken == other.wireToken && additionalProperties == other.additionalProperties } @@ -8416,10 +11532,13 @@ private constructor( externalBankName, externalBankRoutingNumber, externalIndividualName, + imad, lithicBankName, lithicBankRoutingNumber, lithicIndividualName, + omad, previousTransfer, + wireToken, additionalProperties, ) } @@ -8427,7 +11546,7 @@ private constructor( 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}" + "WireMethodAttributes{wireTransferType=$wireTransferType, externalBankName=$externalBankName, externalBankRoutingNumber=$externalBankRoutingNumber, externalIndividualName=$externalIndividualName, imad=$imad, lithicBankName=$lithicBankName, lithicBankRoutingNumber=$lithicBankRoutingNumber, lithicIndividualName=$lithicIndividualName, omad=$omad, previousTransfer=$previousTransfer, wireToken=$wireToken, additionalProperties=$additionalProperties}" } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt index 41837e8f7..b90b11b61 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt @@ -24,13 +24,13 @@ import kotlin.jvm.optionals.getOrNull /** Book transfer funds between two financial accounts or between a financial account and card */ class BookTransferCreateParams private constructor( - private val body: Body, + private val body: CreateBookTransferRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This should + * Amount to be transferred in the currency's smallest unit (e.g., cents for USD). This should * always be a positive value. * * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -44,7 +44,7 @@ private constructor( * @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(): Category = body.category() + fun category(): BookTransferCategory = body.category() /** * Globally unique identifier for the financial account or card that will send the funds. @@ -73,12 +73,12 @@ private constructor( fun toFinancialAccountToken(): String = body.toFinancialAccountToken() /** - * Type of book_transfer + * Type of the 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 type(): Type = body.type() + fun type(): BookTransferType = body.type() /** * Customer-provided token that will serve as an idempotency token. This token will become the @@ -89,6 +89,14 @@ private constructor( */ fun token(): Optional = body.token() + /** + * External ID defined by the customer + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = body.externalId() + /** * Optional descriptor for the transfer. * @@ -97,6 +105,14 @@ private constructor( */ fun memo(): Optional = body.memo() + /** + * What to do if the financial account is closed when posting an operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun onClosedAccount(): Optional = body.onClosedAccount() + /** * Returns the raw JSON value of [amount]. * @@ -109,7 +125,7 @@ private constructor( * * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. */ - fun _category(): JsonField = body._category() + fun _category(): JsonField = body._category() /** * Returns the raw JSON value of [fromFinancialAccountToken]. @@ -139,7 +155,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun _type(): JsonField = body._type() + fun _type(): JsonField = body._type() /** * Returns the raw JSON value of [token]. @@ -148,6 +164,13 @@ private constructor( */ fun _token(): JsonField = body._token() + /** + * Returns the raw JSON value of [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _externalId(): JsonField = body._externalId() + /** * Returns the raw JSON value of [memo]. * @@ -155,6 +178,13 @@ private constructor( */ fun _memo(): JsonField = body._memo() + /** + * Returns the raw JSON value of [onClosedAccount]. + * + * Unlike [onClosedAccount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _onClosedAccount(): JsonField = body._onClosedAccount() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -186,7 +216,7 @@ private constructor( /** A builder for [BookTransferCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var body: CreateBookTransferRequest.Builder = CreateBookTransferRequest.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -209,10 +239,10 @@ private constructor( * - [toFinancialAccountToken] * - etc. */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun body(body: CreateBookTransferRequest) = apply { this.body = body.toBuilder() } /** - * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * Amount to be transferred in the currency's smallest unit (e.g., cents for USD). This * should always be a positive value. */ fun amount(amount: Long) = apply { body.amount(amount) } @@ -226,16 +256,16 @@ private constructor( fun amount(amount: JsonField) = apply { body.amount(amount) } /** Category of the book transfer */ - fun category(category: Category) = apply { body.category(category) } + fun category(category: BookTransferCategory) = apply { body.category(category) } /** * Sets [Builder.category] to an arbitrary JSON value. * - * You should usually call [Builder.category] with a well-typed [Category] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.category] with a well-typed [BookTransferCategory] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun category(category: JsonField) = apply { body.category(category) } + fun category(category: JsonField) = apply { body.category(category) } /** * Globally unique identifier for the financial account or card that will send the funds. @@ -286,16 +316,17 @@ private constructor( body.toFinancialAccountToken(toFinancialAccountToken) } - /** Type of book_transfer */ - fun type(type: Type) = apply { body.type(type) } + /** Type of the book transfer */ + fun type(type: BookTransferType) = apply { body.type(type) } /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.type] with a well-typed [BookTransferType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = apply { body.type(type) } /** * Customer-provided token that will serve as an idempotency token. This token will become @@ -311,6 +342,18 @@ private constructor( */ fun token(token: JsonField) = apply { body.token(token) } + /** External ID defined by the customer */ + fun externalId(externalId: String) = apply { body.externalId(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 { body.externalId(externalId) } + /** Optional descriptor for the transfer. */ fun memo(memo: String) = apply { body.memo(memo) } @@ -322,6 +365,22 @@ private constructor( */ fun memo(memo: JsonField) = apply { body.memo(memo) } + /** What to do if the financial account is closed when posting an operation */ + fun onClosedAccount(onClosedAccount: OnClosedAccount) = apply { + body.onClosedAccount(onClosedAccount) + } + + /** + * Sets [Builder.onClosedAccount] to an arbitrary JSON value. + * + * You should usually call [Builder.onClosedAccount] with a well-typed [OnClosedAccount] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun onClosedAccount(onClosedAccount: JsonField) = apply { + body.onClosedAccount(onClosedAccount) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -464,22 +523,24 @@ private constructor( ) } - fun _body(): Body = body + fun _body(): CreateBookTransferRequest = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - class Body + class CreateBookTransferRequest private constructor( private val amount: JsonField, - private val category: JsonField, + private val category: JsonField, private val fromFinancialAccountToken: JsonField, private val subtype: JsonField, private val toFinancialAccountToken: JsonField, - private val type: JsonField, + private val type: JsonField, private val token: JsonField, + private val externalId: JsonField, private val memo: JsonField, + private val onClosedAccount: JsonField, private val additionalProperties: MutableMap, ) { @@ -488,7 +549,7 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @JsonProperty("category") @ExcludeMissing - category: JsonField = JsonMissing.of(), + category: JsonField = JsonMissing.of(), @JsonProperty("from_financial_account_token") @ExcludeMissing fromFinancialAccountToken: JsonField = JsonMissing.of(), @@ -496,9 +557,17 @@ private constructor( @JsonProperty("to_financial_account_token") @ExcludeMissing toFinancialAccountToken: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("on_closed_account") + @ExcludeMissing + onClosedAccount: JsonField = JsonMissing.of(), ) : this( amount, category, @@ -507,12 +576,14 @@ private constructor( toFinancialAccountToken, type, token, + externalId, memo, + onClosedAccount, mutableMapOf(), ) /** - * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * Amount to be transferred in the currency's smallest unit (e.g., cents for USD). This * should always be a positive value. * * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -526,7 +597,7 @@ private constructor( * @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(): Category = category.getRequired("category") + fun category(): BookTransferCategory = category.getRequired("category") /** * Globally unique identifier for the financial account or card that will send the funds. @@ -557,12 +628,12 @@ private constructor( toFinancialAccountToken.getRequired("to_financial_account_token") /** - * Type of book_transfer + * Type of the 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 type(): Type = type.getRequired("type") + fun type(): BookTransferType = type.getRequired("type") /** * Customer-provided token that will serve as an idempotency token. This token will become @@ -573,6 +644,14 @@ private constructor( */ fun token(): Optional = token.getOptional("token") + /** + * External ID defined by the customer + * + * @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") + /** * Optional descriptor for the transfer. * @@ -581,6 +660,15 @@ private constructor( */ fun memo(): Optional = memo.getOptional("memo") + /** + * What to do if the financial account is closed when posting an operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun onClosedAccount(): Optional = + onClosedAccount.getOptional("on_closed_account") + /** * Returns the raw JSON value of [amount]. * @@ -593,7 +681,9 @@ private constructor( * * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category /** * Returns the raw JSON value of [fromFinancialAccountToken]. @@ -627,7 +717,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [token]. @@ -636,6 +726,15 @@ private constructor( */ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + /** + * 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 [memo]. * @@ -643,6 +742,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [onClosedAccount]. + * + * Unlike [onClosedAccount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_closed_account") + @ExcludeMissing + fun _onClosedAccount(): JsonField = onClosedAccount + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -658,7 +767,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Body]. + * Returns a mutable builder for constructing an instance of + * [CreateBookTransferRequest]. * * The following fields are required: * ```java @@ -673,34 +783,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [Body]. */ + /** A builder for [CreateBookTransferRequest]. */ class Builder internal constructor() { private var amount: JsonField? = null - private var category: JsonField? = null + private var category: JsonField? = null private var fromFinancialAccountToken: JsonField? = null private var subtype: JsonField? = null private var toFinancialAccountToken: JsonField? = null - private var type: JsonField? = null + private var type: JsonField? = null private var token: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var onClosedAccount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - amount = body.amount - category = body.category - fromFinancialAccountToken = body.fromFinancialAccountToken - subtype = body.subtype - toFinancialAccountToken = body.toFinancialAccountToken - type = body.type - token = body.token - memo = body.memo - additionalProperties = body.additionalProperties.toMutableMap() + internal fun from(createBookTransferRequest: CreateBookTransferRequest) = apply { + amount = createBookTransferRequest.amount + category = createBookTransferRequest.category + fromFinancialAccountToken = createBookTransferRequest.fromFinancialAccountToken + subtype = createBookTransferRequest.subtype + toFinancialAccountToken = createBookTransferRequest.toFinancialAccountToken + type = createBookTransferRequest.type + token = createBookTransferRequest.token + externalId = createBookTransferRequest.externalId + memo = createBookTransferRequest.memo + onClosedAccount = createBookTransferRequest.onClosedAccount + additionalProperties = createBookTransferRequest.additionalProperties.toMutableMap() } /** - * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * Amount to be transferred in the currency's smallest unit (e.g., cents for USD). This * should always be a positive value. */ fun amount(amount: Long) = amount(JsonField.of(amount)) @@ -715,16 +829,18 @@ private constructor( fun amount(amount: JsonField) = apply { this.amount = amount } /** Category of the book transfer */ - fun category(category: Category) = category(JsonField.of(category)) + fun category(category: BookTransferCategory) = category(JsonField.of(category)) /** * Sets [Builder.category] to an arbitrary JSON value. * - * You should usually call [Builder.category] with a well-typed [Category] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.category] with a well-typed [BookTransferCategory] + * 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 } + fun category(category: JsonField) = apply { + this.category = category + } /** * Globally unique identifier for the financial account or card that will send the @@ -774,17 +890,17 @@ private constructor( this.toFinancialAccountToken = toFinancialAccountToken } - /** Type of book_transfer */ - fun type(type: Type) = type(JsonField.of(type)) + /** Type of the book transfer */ + fun type(type: BookTransferType) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.type] with a well-typed [BookTransferType] 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 type(type: JsonField) = apply { this.type = type } /** * Customer-provided token that will serve as an idempotency token. This token will @@ -801,6 +917,18 @@ private constructor( */ fun token(token: JsonField) = apply { this.token = token } + /** External ID defined by the customer */ + 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 } + /** Optional descriptor for the transfer. */ fun memo(memo: String) = memo(JsonField.of(memo)) @@ -813,6 +941,21 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** What to do if the financial account is closed when posting an operation */ + fun onClosedAccount(onClosedAccount: OnClosedAccount) = + onClosedAccount(JsonField.of(onClosedAccount)) + + /** + * Sets [Builder.onClosedAccount] to an arbitrary JSON value. + * + * You should usually call [Builder.onClosedAccount] with a well-typed [OnClosedAccount] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun onClosedAccount(onClosedAccount: JsonField) = apply { + this.onClosedAccount = onClosedAccount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -833,7 +976,7 @@ private constructor( } /** - * Returns an immutable instance of [Body]. + * Returns an immutable instance of [CreateBookTransferRequest]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -849,8 +992,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Body = - Body( + fun build(): CreateBookTransferRequest = + CreateBookTransferRequest( checkRequired("amount", amount), checkRequired("category", category), checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), @@ -858,14 +1001,16 @@ private constructor( checkRequired("toFinancialAccountToken", toFinancialAccountToken), checkRequired("type", type), token, + externalId, memo, + onClosedAccount, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): CreateBookTransferRequest = apply { if (validated) { return@apply } @@ -877,7 +1022,9 @@ private constructor( toFinancialAccountToken() type().validate() token() + externalId() memo() + onClosedAccount().ifPresent { it.validate() } validated = true } @@ -904,14 +1051,16 @@ private constructor( (if (toFinancialAccountToken.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (token.asKnown().isPresent) 1 else 0) + - (if (memo.asKnown().isPresent) 1 else 0) + (if (externalId.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (onClosedAccount.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Body && + return other is CreateBookTransferRequest && amount == other.amount && category == other.category && fromFinancialAccountToken == other.fromFinancialAccountToken && @@ -919,7 +1068,9 @@ private constructor( toFinancialAccountToken == other.toFinancialAccountToken && type == other.type && token == other.token && + externalId == other.externalId && memo == other.memo && + onClosedAccount == other.onClosedAccount && additionalProperties == other.additionalProperties } @@ -932,7 +1083,9 @@ private constructor( toFinancialAccountToken, type, token, + externalId, memo, + onClosedAccount, additionalProperties, ) } @@ -940,11 +1093,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{amount=$amount, category=$category, fromFinancialAccountToken=$fromFinancialAccountToken, subtype=$subtype, toFinancialAccountToken=$toFinancialAccountToken, type=$type, token=$token, memo=$memo, additionalProperties=$additionalProperties}" + "CreateBookTransferRequest{amount=$amount, category=$category, fromFinancialAccountToken=$fromFinancialAccountToken, subtype=$subtype, toFinancialAccountToken=$toFinancialAccountToken, type=$type, token=$token, externalId=$externalId, memo=$memo, onClosedAccount=$onClosedAccount, additionalProperties=$additionalProperties}" } /** Category of the book transfer */ - class Category @JsonCreator private constructor(private val value: JsonField) : Enum { + class BookTransferCategory + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -972,10 +1127,10 @@ private constructor( @JvmField val TRANSFER = of("TRANSFER") - @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + @JvmStatic fun of(value: String) = BookTransferCategory(JsonField.of(value)) } - /** An enum containing [Category]'s known values. */ + /** An enum containing [BookTransferCategory]'s known values. */ enum class Known { ADJUSTMENT, BALANCE_OR_FUNDING, @@ -987,9 +1142,10 @@ private constructor( } /** - * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BookTransferCategory]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [Category] can contain an unknown value in a couple of cases: + * An instance of [BookTransferCategory] 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. @@ -1003,7 +1159,10 @@ private constructor( FEE, REWARD, TRANSFER, - /** An enum member indicating that [Category] was instantiated with an unknown value. */ + /** + * An enum member indicating that [BookTransferCategory] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1044,7 +1203,7 @@ private constructor( FEE -> Known.FEE REWARD -> Known.REWARD TRANSFER -> Known.TRANSFER - else -> throw LithicInvalidDataException("Unknown Category: $value") + else -> throw LithicInvalidDataException("Unknown BookTransferCategory: $value") } /** @@ -1061,7 +1220,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Category = apply { + fun validate(): BookTransferCategory = apply { if (validated) { return@apply } @@ -1091,7 +1250,7 @@ private constructor( return true } - return other is Category && value == other.value + return other is BookTransferCategory && value == other.value } override fun hashCode() = value.hashCode() @@ -1099,8 +1258,9 @@ private constructor( override fun toString() = value.toString() } - /** Type of book_transfer */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + /** Type of the book transfer */ + class BookTransferType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1180,10 +1340,10 @@ private constructor( @JvmField val TRANSFER = of("TRANSFER") - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun of(value: String) = BookTransferType(JsonField.of(value)) } - /** An enum containing [Type]'s known values. */ + /** An enum containing [BookTransferType]'s known values. */ enum class Known { ATM_WITHDRAWAL, ATM_DECLINE, @@ -1221,9 +1381,9 @@ private constructor( } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BookTransferType]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Type] can contain an unknown value in a couple of cases: + * An instance of [BookTransferType] 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. @@ -1263,7 +1423,10 @@ private constructor( DISPUTE_WON, SERVICE, TRANSFER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [BookTransferType] was instantiated with an unknown + * value. + */ _UNKNOWN, } @@ -1356,7 +1519,137 @@ private constructor( DISPUTE_WON -> Known.DISPUTE_WON SERVICE -> Known.SERVICE TRANSFER -> Known.TRANSFER - else -> throw LithicInvalidDataException("Unknown Type: $value") + else -> throw LithicInvalidDataException("Unknown BookTransferType: $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(): BookTransferType = 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 other is BookTransferType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** What to do if the financial account is closed when posting an operation */ + class OnClosedAccount @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 FAIL = of("FAIL") + + @JvmField val USE_SUSPENSE = of("USE_SUSPENSE") + + @JvmStatic fun of(value: String) = OnClosedAccount(JsonField.of(value)) + } + + /** An enum containing [OnClosedAccount]'s known values. */ + enum class Known { + FAIL, + USE_SUSPENSE, + } + + /** + * An enum containing [OnClosedAccount]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OnClosedAccount] 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 { + FAIL, + USE_SUSPENSE, + /** + * An enum member indicating that [OnClosedAccount] 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) { + FAIL -> Value.FAIL + USE_SUSPENSE -> Value.USE_SUSPENSE + 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) { + FAIL -> Known.FAIL + USE_SUSPENSE -> Known.USE_SUSPENSE + else -> throw LithicInvalidDataException("Unknown OnClosedAccount: $value") } /** @@ -1373,7 +1666,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Type = apply { + fun validate(): OnClosedAccount = apply { if (validated) { return@apply } @@ -1403,7 +1696,7 @@ private constructor( return true } - return other is Type && value == other.value + return other is OnClosedAccount && value == other.value } override fun hashCode() = value.hashCode() 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 02b84e2fa..e6ff91d79 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 @@ -24,17 +24,18 @@ import kotlin.jvm.optionals.getOrNull class BookTransferResponse private constructor( private val token: JsonField, - private val category: JsonField, + private val category: JsonField, private val created: JsonField, private val currency: JsonField, private val events: JsonField>, + private val externalId: JsonField, private val externalResource: JsonField, private val fromFinancialAccountToken: JsonField, private val pendingAmount: JsonField, - private val result: JsonField, + private val result: JsonField, private val settledAmount: JsonField, private val status: JsonField, - private val toFinancialAccountToken: JsonValue, + private val toFinancialAccountToken: JsonField, private val transactionSeries: JsonField, private val updated: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +44,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("category") @ExcludeMissing category: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), @@ -51,6 +54,9 @@ private constructor( @JsonProperty("events") @ExcludeMissing events: JsonField> = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), @JsonProperty("external_resource") @ExcludeMissing externalResource: JsonField = JsonMissing.of(), @@ -60,14 +66,16 @@ private constructor( @JsonProperty("pending_amount") @ExcludeMissing pendingAmount: JsonField = JsonMissing.of(), - @JsonProperty("result") @ExcludeMissing result: 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: JsonValue = JsonMissing.of(), + toFinancialAccountToken: JsonField = JsonMissing.of(), @JsonProperty("transaction_series") @ExcludeMissing transactionSeries: JsonField = JsonMissing.of(), @@ -80,6 +88,7 @@ private constructor( created, currency, events, + externalId, externalResource, fromFinancialAccountToken, pendingAmount, @@ -107,7 +116,7 @@ private constructor( * @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(): Category = category.getRequired("category") + fun category(): BookTransferCategory = category.getRequired("category") /** * Date and time when the transfer occurred. UTC time zone. @@ -133,6 +142,14 @@ private constructor( */ fun events(): List = events.getRequired("events") + /** + * External ID defined by the customer + * + * @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 * @@ -154,8 +171,9 @@ private constructor( /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including - * any acquirer fees. The value of this field will go to zero over time once the financial - * transaction is settled. + * any acquirer fees. + * + * The value of this field will go to zero over time once the financial transaction is settled. * * @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). @@ -163,13 +181,10 @@ private constructor( fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") /** - * APPROVED transactions were successful while DECLINED transactions were declined by user, - * Lithic, or the network. - * * @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(): Result = result.getRequired("result") + fun result(): TransactionResult = result.getRequired("result") /** * Amount of the transaction that has been settled in the currency's smallest unit (e.g., @@ -181,8 +196,10 @@ private constructor( fun settledAmount(): Long = settledAmount.getRequired("settled_amount") /** - * Status types: _ `DECLINED` - The transfer was declined. _ `REVERSED` - The transfer was - * reversed \* `SETTLED` - The transfer is completed. + * Status types: + * - `DECLINED` - The transfer was declined. + * - `REVERSED` - The transfer was reversed + * - `SETTLED` - The transfer is completed. * * @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). @@ -192,10 +209,12 @@ private constructor( /** * Globally unique identifier for the financial account or card that will receive the funds. * Accepted type dependent on the program's use case. + * + * @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). */ - @JsonProperty("to_financial_account_token") - @ExcludeMissing - fun _toFinancialAccountToken(): JsonValue = toFinancialAccountToken + fun toFinancialAccountToken(): String = + toFinancialAccountToken.getRequired("to_financial_account_token") /** * A series of transactions that are grouped together. @@ -226,7 +245,9 @@ private constructor( * * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category /** * Returns the raw JSON value of [created]. @@ -251,6 +272,13 @@ private constructor( @ExcludeMissing fun _events(): JsonField> = events + /** + * 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]. * @@ -285,7 +313,7 @@ private constructor( * * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Returns the raw JSON value of [settledAmount]. @@ -303,6 +331,16 @@ private constructor( */ @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 [transactionSeries]. * @@ -344,6 +382,7 @@ private constructor( * .created() * .currency() * .events() + * .externalId() * .externalResource() * .fromFinancialAccountToken() * .pendingAmount() @@ -362,17 +401,18 @@ private constructor( class Builder internal constructor() { private var token: JsonField? = null - private var category: JsonField? = null + private var category: JsonField? = null private var created: JsonField? = null private var currency: JsonField? = null private var events: JsonField>? = null + private var externalId: JsonField? = null private var externalResource: JsonField? = null private var fromFinancialAccountToken: JsonField? = null private var pendingAmount: JsonField? = null - private var result: JsonField? = null + private var result: JsonField? = null private var settledAmount: JsonField? = null private var status: JsonField? = null - private var toFinancialAccountToken: JsonValue? = null + private var toFinancialAccountToken: JsonField? = null private var transactionSeries: JsonField? = null private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -384,6 +424,7 @@ private constructor( created = bookTransferResponse.created currency = bookTransferResponse.currency events = bookTransferResponse.events.map { it.toMutableList() } + externalId = bookTransferResponse.externalId externalResource = bookTransferResponse.externalResource fromFinancialAccountToken = bookTransferResponse.fromFinancialAccountToken pendingAmount = bookTransferResponse.pendingAmount @@ -411,16 +452,16 @@ private constructor( fun token(token: JsonField) = apply { this.token = token } /** Category of the book transfer */ - fun category(category: Category) = category(JsonField.of(category)) + fun category(category: BookTransferCategory) = category(JsonField.of(category)) /** * Sets [Builder.category] to an arbitrary JSON value. * - * You should usually call [Builder.category] with a well-typed [Category] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.category] with a well-typed [BookTransferCategory] 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 } + fun category(category: JsonField) = apply { this.category = category } /** Date and time when the transfer occurred. UTC time zone. */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -471,6 +512,21 @@ private constructor( } } + /** External ID defined by the customer */ + fun externalId(externalId: String?) = externalId(JsonField.ofNullable(externalId)) + + /** Alias for calling [Builder.externalId] with `externalId.orElse(null)`. */ + fun externalId(externalId: Optional) = externalId(externalId.getOrNull()) + + /** + * 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)) @@ -510,8 +566,10 @@ private constructor( /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), - * including any acquirer fees. The value of this field will go to zero over time once the - * financial transaction is settled. + * including any acquirer fees. + * + * The value of this field will go to zero over time once the financial transaction is + * settled. */ fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) @@ -526,19 +584,16 @@ private constructor( this.pendingAmount = pendingAmount } - /** - * APPROVED transactions were successful while DECLINED transactions were declined by user, - * Lithic, or the network. - */ - fun result(result: Result) = result(JsonField.of(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 [Result] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported 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 } + fun result(result: JsonField) = apply { this.result = result } /** * Amount of the transaction that has been settled in the currency's smallest unit (e.g., @@ -558,8 +613,10 @@ private constructor( } /** - * Status types: _ `DECLINED` - The transfer was declined. _ `REVERSED` - The transfer was - * reversed \* `SETTLED` - The transfer is completed. + * Status types: + * - `DECLINED` - The transfer was declined. + * - `REVERSED` - The transfer was reversed + * - `SETTLED` - The transfer is completed. */ fun status(status: Status) = status(JsonField.of(status)) @@ -575,7 +632,17 @@ private constructor( * Globally unique identifier for the financial account or card that will receive the funds. * Accepted type dependent on the program's use case. */ - fun toFinancialAccountToken(toFinancialAccountToken: JsonValue) = apply { + 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 } @@ -641,6 +708,7 @@ private constructor( * .created() * .currency() * .events() + * .externalId() * .externalResource() * .fromFinancialAccountToken() * .pendingAmount() @@ -661,6 +729,7 @@ private constructor( checkRequired("created", created), checkRequired("currency", currency), checkRequired("events", events).map { it.toImmutable() }, + checkRequired("externalId", externalId), checkRequired("externalResource", externalResource), checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), checkRequired("pendingAmount", pendingAmount), @@ -686,12 +755,14 @@ private constructor( created() currency() events().forEach { it.validate() } + externalId() externalResource().ifPresent { it.validate() } fromFinancialAccountToken() pendingAmount() result().validate() settledAmount() status().validate() + toFinancialAccountToken() transactionSeries().ifPresent { it.validate() } updated() validated = true @@ -717,17 +788,21 @@ private constructor( (if (created.asKnown().isPresent) 1 else 0) + (if (currency.asKnown().isPresent) 1 else 0) + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 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) + + (if (toFinancialAccountToken.asKnown().isPresent) 1 else 0) + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + (if (updated.asKnown().isPresent) 1 else 0) /** Category of the book transfer */ - class Category @JsonCreator private constructor(private val value: JsonField) : Enum { + class BookTransferCategory + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -755,10 +830,10 @@ private constructor( @JvmField val TRANSFER = of("TRANSFER") - @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + @JvmStatic fun of(value: String) = BookTransferCategory(JsonField.of(value)) } - /** An enum containing [Category]'s known values. */ + /** An enum containing [BookTransferCategory]'s known values. */ enum class Known { ADJUSTMENT, BALANCE_OR_FUNDING, @@ -770,9 +845,10 @@ private constructor( } /** - * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BookTransferCategory]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [Category] can contain an unknown value in a couple of cases: + * An instance of [BookTransferCategory] 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. @@ -786,7 +862,10 @@ private constructor( FEE, REWARD, TRANSFER, - /** An enum member indicating that [Category] was instantiated with an unknown value. */ + /** + * An enum member indicating that [BookTransferCategory] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -827,7 +906,7 @@ private constructor( FEE -> Known.FEE REWARD -> Known.REWARD TRANSFER -> Known.TRANSFER - else -> throw LithicInvalidDataException("Unknown Category: $value") + else -> throw LithicInvalidDataException("Unknown BookTransferCategory: $value") } /** @@ -844,7 +923,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Category = apply { + fun validate(): BookTransferCategory = apply { if (validated) { return@apply } @@ -874,7 +953,7 @@ private constructor( return true } - return other is Category && value == other.value + return other is BookTransferCategory && value == other.value } override fun hashCode() = value.hashCode() @@ -882,16 +961,17 @@ private constructor( override fun toString() = value.toString() } + /** Book transfer Event */ class BookTransferEvent private constructor( private val token: JsonField, private val amount: JsonField, private val created: JsonField, - private val detailedResults: JsonField>, + private val detailedResults: JsonField, private val memo: JsonField, private val result: JsonField, private val subtype: JsonField, - private val type: JsonField, + private val type: JsonField, private val additionalProperties: MutableMap, ) { @@ -904,11 +984,13 @@ private constructor( created: JsonField = JsonMissing.of(), @JsonProperty("detailed_results") @ExcludeMissing - detailedResults: JsonField> = JsonMissing.of(), + detailedResults: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), @JsonProperty("subtype") @ExcludeMissing subtype: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), ) : this( token, amount, @@ -947,12 +1029,10 @@ private constructor( fun created(): OffsetDateTime = created.getRequired("created") /** - * Detailed Results - * * @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 detailedResults(): List = + fun detailedResults(): BookTransferDetailedResults = detailedResults.getRequired("detailed_results") /** @@ -986,7 +1066,7 @@ private constructor( * @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") + fun type(): BookTransferType = type.getRequired("type") /** * Returns the raw JSON value of [token]. @@ -1017,7 +1097,7 @@ private constructor( */ @JsonProperty("detailed_results") @ExcludeMissing - fun _detailedResults(): JsonField> = detailedResults + fun _detailedResults(): JsonField = detailedResults /** * Returns the raw JSON value of [memo]. @@ -1045,7 +1125,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1085,11 +1165,11 @@ private constructor( private var token: JsonField? = null private var amount: JsonField? = null private var created: JsonField? = null - private var detailedResults: JsonField>? = null + private var detailedResults: JsonField? = null private var memo: JsonField? = null private var result: JsonField? = null private var subtype: JsonField? = null - private var type: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1097,7 +1177,7 @@ private constructor( token = bookTransferEvent.token amount = bookTransferEvent.amount created = bookTransferEvent.created - detailedResults = bookTransferEvent.detailedResults.map { it.toMutableList() } + detailedResults = bookTransferEvent.detailedResults memo = bookTransferEvent.memo result = bookTransferEvent.result subtype = bookTransferEvent.subtype @@ -1144,31 +1224,18 @@ private constructor( */ fun created(created: JsonField) = apply { this.created = created } - /** Detailed Results */ - fun detailedResults(detailedResults: List) = + fun detailedResults(detailedResults: BookTransferDetailedResults) = detailedResults(JsonField.of(detailedResults)) /** * Sets [Builder.detailedResults] to an arbitrary JSON value. * * You should usually call [Builder.detailedResults] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun detailedResults(detailedResults: JsonField>) = apply { - this.detailedResults = detailedResults.map { it.toMutableList() } - } - - /** - * Adds a single [DetailedResult] to [detailedResults]. - * - * @throws IllegalStateException if the field was previously set to a non-list. + * [BookTransferDetailedResults] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun addDetailedResult(detailedResult: DetailedResult) = apply { - detailedResults = - (detailedResults ?: JsonField.of(mutableListOf())).also { - checkKnown("detailedResults", it).add(detailedResult) - } + fun detailedResults(detailedResults: JsonField) = apply { + this.detailedResults = detailedResults } /** Memo for the transfer. */ @@ -1211,16 +1278,16 @@ private constructor( fun subtype(subtype: JsonField) = apply { this.subtype = subtype } /** Type of the book transfer */ - fun type(type: String) = type(JsonField.of(type)) + fun type(type: BookTransferType) = 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. + * You should usually call [Builder.type] with a well-typed [BookTransferType] 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 type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1265,7 +1332,7 @@ private constructor( checkRequired("token", token), checkRequired("amount", amount), checkRequired("created", created), - checkRequired("detailedResults", detailedResults).map { it.toImmutable() }, + checkRequired("detailedResults", detailedResults), checkRequired("memo", memo), checkRequired("result", result), checkRequired("subtype", subtype), @@ -1284,11 +1351,11 @@ private constructor( token() amount() created() - detailedResults().forEach { it.validate() } + detailedResults().validate() memo() result().validate() subtype() - type() + type().validate() validated = true } @@ -1311,13 +1378,13 @@ private constructor( (if (token.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + (if (created.asKnown().isPresent) 1 else 0) + - (detailedResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (detailedResults.asKnown().getOrNull()?.validity() ?: 0) + (if (memo.asKnown().isPresent) 1 else 0) + (result.asKnown().getOrNull()?.validity() ?: 0) + (if (subtype.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - class DetailedResult + class BookTransferDetailedResults @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1337,19 +1404,21 @@ private constructor( @JvmField val FUNDS_INSUFFICIENT = of("FUNDS_INSUFFICIENT") - @JvmStatic fun of(value: String) = DetailedResult(JsonField.of(value)) + @JvmStatic fun of(value: String) = BookTransferDetailedResults(JsonField.of(value)) } - /** An enum containing [DetailedResult]'s known values. */ + /** An enum containing [BookTransferDetailedResults]'s known values. */ enum class Known { APPROVED, FUNDS_INSUFFICIENT, } /** - * An enum containing [DetailedResult]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BookTransferDetailedResults]'s known values, as well as an + * [_UNKNOWN] member. * - * An instance of [DetailedResult] can contain an unknown value in a couple of cases: + * An instance of [BookTransferDetailedResults] 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. @@ -1359,8 +1428,8 @@ private constructor( APPROVED, FUNDS_INSUFFICIENT, /** - * An enum member indicating that [DetailedResult] was instantiated with an unknown - * value. + * An enum member indicating that [BookTransferDetailedResults] was instantiated + * with an unknown value. */ _UNKNOWN, } @@ -1392,7 +1461,10 @@ private constructor( when (this) { APPROVED -> Known.APPROVED FUNDS_INSUFFICIENT -> Known.FUNDS_INSUFFICIENT - else -> throw LithicInvalidDataException("Unknown DetailedResult: $value") + else -> + throw LithicInvalidDataException( + "Unknown BookTransferDetailedResults: $value" + ) } /** @@ -1411,7 +1483,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DetailedResult = apply { + fun validate(): BookTransferDetailedResults = apply { if (validated) { return@apply } @@ -1441,7 +1513,7 @@ private constructor( return true } - return other is DetailedResult && value == other.value + return other is BookTransferDetailedResults && value == other.value } override fun hashCode() = value.hashCode() @@ -1582,6 +1654,326 @@ private constructor( override fun toString() = value.toString() } + /** Type of the book transfer */ + class BookTransferType + @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 ATM_WITHDRAWAL = of("ATM_WITHDRAWAL") + + @JvmField val ATM_DECLINE = of("ATM_DECLINE") + + @JvmField val INTERNATIONAL_ATM_WITHDRAWAL = of("INTERNATIONAL_ATM_WITHDRAWAL") + + @JvmField val INACTIVITY = of("INACTIVITY") + + @JvmField val STATEMENT = of("STATEMENT") + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val CUSTOMER_SERVICE = of("CUSTOMER_SERVICE") + + @JvmField val ACCOUNT_MAINTENANCE = of("ACCOUNT_MAINTENANCE") + + @JvmField val ACCOUNT_ACTIVATION = of("ACCOUNT_ACTIVATION") + + @JvmField val ACCOUNT_CLOSURE = of("ACCOUNT_CLOSURE") + + @JvmField val CARD_REPLACEMENT = of("CARD_REPLACEMENT") + + @JvmField val CARD_DELIVERY = of("CARD_DELIVERY") + + @JvmField val CARD_CREATE = of("CARD_CREATE") + + @JvmField val CURRENCY_CONVERSION = of("CURRENCY_CONVERSION") + + @JvmField val INTEREST = of("INTEREST") + + @JvmField val LATE_PAYMENT = of("LATE_PAYMENT") + + @JvmField val BILL_PAYMENT = of("BILL_PAYMENT") + + @JvmField val CASH_BACK = of("CASH_BACK") + + @JvmField val ACCOUNT_TO_ACCOUNT = of("ACCOUNT_TO_ACCOUNT") + + @JvmField val CARD_TO_CARD = of("CARD_TO_CARD") + + @JvmField val DISBURSE = of("DISBURSE") + + @JvmField val BILLING_ERROR = of("BILLING_ERROR") + + @JvmField val LOSS_WRITE_OFF = of("LOSS_WRITE_OFF") + + @JvmField val EXPIRED_CARD = of("EXPIRED_CARD") + + @JvmField val EARLY_DERECOGNITION = of("EARLY_DERECOGNITION") + + @JvmField val ESCHEATMENT = of("ESCHEATMENT") + + @JvmField val INACTIVITY_FEE_DOWN = of("INACTIVITY_FEE_DOWN") + + @JvmField val PROVISIONAL_CREDIT = of("PROVISIONAL_CREDIT") + + @JvmField val DISPUTE_WON = of("DISPUTE_WON") + + @JvmField val SERVICE = of("SERVICE") + + @JvmField val TRANSFER = of("TRANSFER") + + @JvmStatic fun of(value: String) = BookTransferType(JsonField.of(value)) + } + + /** An enum containing [BookTransferType]'s known values. */ + enum class Known { + ATM_WITHDRAWAL, + ATM_DECLINE, + INTERNATIONAL_ATM_WITHDRAWAL, + INACTIVITY, + STATEMENT, + MONTHLY, + QUARTERLY, + ANNUAL, + CUSTOMER_SERVICE, + ACCOUNT_MAINTENANCE, + ACCOUNT_ACTIVATION, + ACCOUNT_CLOSURE, + CARD_REPLACEMENT, + CARD_DELIVERY, + CARD_CREATE, + CURRENCY_CONVERSION, + INTEREST, + LATE_PAYMENT, + BILL_PAYMENT, + CASH_BACK, + ACCOUNT_TO_ACCOUNT, + CARD_TO_CARD, + DISBURSE, + BILLING_ERROR, + LOSS_WRITE_OFF, + EXPIRED_CARD, + EARLY_DERECOGNITION, + ESCHEATMENT, + INACTIVITY_FEE_DOWN, + PROVISIONAL_CREDIT, + DISPUTE_WON, + SERVICE, + TRANSFER, + } + + /** + * An enum containing [BookTransferType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BookTransferType] 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 { + ATM_WITHDRAWAL, + ATM_DECLINE, + INTERNATIONAL_ATM_WITHDRAWAL, + INACTIVITY, + STATEMENT, + MONTHLY, + QUARTERLY, + ANNUAL, + CUSTOMER_SERVICE, + ACCOUNT_MAINTENANCE, + ACCOUNT_ACTIVATION, + ACCOUNT_CLOSURE, + CARD_REPLACEMENT, + CARD_DELIVERY, + CARD_CREATE, + CURRENCY_CONVERSION, + INTEREST, + LATE_PAYMENT, + BILL_PAYMENT, + CASH_BACK, + ACCOUNT_TO_ACCOUNT, + CARD_TO_CARD, + DISBURSE, + BILLING_ERROR, + LOSS_WRITE_OFF, + EXPIRED_CARD, + EARLY_DERECOGNITION, + ESCHEATMENT, + INACTIVITY_FEE_DOWN, + PROVISIONAL_CREDIT, + DISPUTE_WON, + SERVICE, + TRANSFER, + /** + * An enum member indicating that [BookTransferType] 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) { + ATM_WITHDRAWAL -> Value.ATM_WITHDRAWAL + ATM_DECLINE -> Value.ATM_DECLINE + INTERNATIONAL_ATM_WITHDRAWAL -> Value.INTERNATIONAL_ATM_WITHDRAWAL + INACTIVITY -> Value.INACTIVITY + STATEMENT -> Value.STATEMENT + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ANNUAL -> Value.ANNUAL + CUSTOMER_SERVICE -> Value.CUSTOMER_SERVICE + ACCOUNT_MAINTENANCE -> Value.ACCOUNT_MAINTENANCE + ACCOUNT_ACTIVATION -> Value.ACCOUNT_ACTIVATION + ACCOUNT_CLOSURE -> Value.ACCOUNT_CLOSURE + CARD_REPLACEMENT -> Value.CARD_REPLACEMENT + CARD_DELIVERY -> Value.CARD_DELIVERY + CARD_CREATE -> Value.CARD_CREATE + CURRENCY_CONVERSION -> Value.CURRENCY_CONVERSION + INTEREST -> Value.INTEREST + LATE_PAYMENT -> Value.LATE_PAYMENT + BILL_PAYMENT -> Value.BILL_PAYMENT + CASH_BACK -> Value.CASH_BACK + ACCOUNT_TO_ACCOUNT -> Value.ACCOUNT_TO_ACCOUNT + CARD_TO_CARD -> Value.CARD_TO_CARD + DISBURSE -> Value.DISBURSE + BILLING_ERROR -> Value.BILLING_ERROR + LOSS_WRITE_OFF -> Value.LOSS_WRITE_OFF + EXPIRED_CARD -> Value.EXPIRED_CARD + EARLY_DERECOGNITION -> Value.EARLY_DERECOGNITION + ESCHEATMENT -> Value.ESCHEATMENT + INACTIVITY_FEE_DOWN -> Value.INACTIVITY_FEE_DOWN + PROVISIONAL_CREDIT -> Value.PROVISIONAL_CREDIT + DISPUTE_WON -> Value.DISPUTE_WON + SERVICE -> Value.SERVICE + TRANSFER -> Value.TRANSFER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ATM_WITHDRAWAL -> Known.ATM_WITHDRAWAL + ATM_DECLINE -> Known.ATM_DECLINE + INTERNATIONAL_ATM_WITHDRAWAL -> Known.INTERNATIONAL_ATM_WITHDRAWAL + INACTIVITY -> Known.INACTIVITY + STATEMENT -> Known.STATEMENT + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ANNUAL -> Known.ANNUAL + CUSTOMER_SERVICE -> Known.CUSTOMER_SERVICE + ACCOUNT_MAINTENANCE -> Known.ACCOUNT_MAINTENANCE + ACCOUNT_ACTIVATION -> Known.ACCOUNT_ACTIVATION + ACCOUNT_CLOSURE -> Known.ACCOUNT_CLOSURE + CARD_REPLACEMENT -> Known.CARD_REPLACEMENT + CARD_DELIVERY -> Known.CARD_DELIVERY + CARD_CREATE -> Known.CARD_CREATE + CURRENCY_CONVERSION -> Known.CURRENCY_CONVERSION + INTEREST -> Known.INTEREST + LATE_PAYMENT -> Known.LATE_PAYMENT + BILL_PAYMENT -> Known.BILL_PAYMENT + CASH_BACK -> Known.CASH_BACK + ACCOUNT_TO_ACCOUNT -> Known.ACCOUNT_TO_ACCOUNT + CARD_TO_CARD -> Known.CARD_TO_CARD + DISBURSE -> Known.DISBURSE + BILLING_ERROR -> Known.BILLING_ERROR + LOSS_WRITE_OFF -> Known.LOSS_WRITE_OFF + EXPIRED_CARD -> Known.EXPIRED_CARD + EARLY_DERECOGNITION -> Known.EARLY_DERECOGNITION + ESCHEATMENT -> Known.ESCHEATMENT + INACTIVITY_FEE_DOWN -> Known.INACTIVITY_FEE_DOWN + PROVISIONAL_CREDIT -> Known.PROVISIONAL_CREDIT + DISPUTE_WON -> Known.DISPUTE_WON + SERVICE -> Known.SERVICE + TRANSFER -> Known.TRANSFER + else -> throw LithicInvalidDataException("Unknown BookTransferType: $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(): BookTransferType = 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 other is BookTransferType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1619,11 +2011,8 @@ private constructor( "BookTransferEvent{token=$token, amount=$amount, created=$created, detailedResults=$detailedResults, memo=$memo, result=$result, subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" } - /** - * APPROVED transactions were successful while DECLINED transactions were declined by user, - * Lithic, or the network. - */ - class Result @JsonCreator private constructor(private val value: JsonField) : Enum { + class TransactionResult @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1641,19 +2030,19 @@ private constructor( @JvmField val DECLINED = of("DECLINED") - @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) } - /** An enum containing [Result]'s known values. */ + /** An enum containing [TransactionResult]'s known values. */ enum class Known { APPROVED, DECLINED, } /** - * An enum containing [Result]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Result] can contain an unknown value in a couple of cases: + * 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. @@ -1662,7 +2051,10 @@ private constructor( enum class Value { APPROVED, DECLINED, - /** An enum member indicating that [Result] was instantiated with an unknown value. */ + /** + * An enum member indicating that [TransactionResult] was instantiated with an unknown + * value. + */ _UNKNOWN, } @@ -1693,7 +2085,7 @@ private constructor( when (this) { APPROVED -> Known.APPROVED DECLINED -> Known.DECLINED - else -> throw LithicInvalidDataException("Unknown Result: $value") + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") } /** @@ -1710,7 +2102,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Result = apply { + fun validate(): TransactionResult = apply { if (validated) { return@apply } @@ -1740,7 +2132,7 @@ private constructor( return true } - return other is Result && value == other.value + return other is TransactionResult && value == other.value } override fun hashCode() = value.hashCode() @@ -1749,8 +2141,10 @@ private constructor( } /** - * Status types: _ `DECLINED` - The transfer was declined. _ `REVERSED` - The transfer was - * reversed \* `SETTLED` - The transfer is completed. + * Status types: + * - `DECLINED` - The transfer was declined. + * - `REVERSED` - The transfer was reversed + * - `SETTLED` - The transfer is completed. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2160,6 +2554,7 @@ private constructor( created == other.created && currency == other.currency && events == other.events && + externalId == other.externalId && externalResource == other.externalResource && fromFinancialAccountToken == other.fromFinancialAccountToken && pendingAmount == other.pendingAmount && @@ -2179,6 +2574,7 @@ private constructor( created, currency, events, + externalId, externalResource, fromFinancialAccountToken, pendingAmount, @@ -2195,5 +2591,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "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}" + "BookTransferResponse{token=$token, category=$category, created=$created, currency=$currency, events=$events, externalId=$externalId, 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/FinancialAccount.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt index 1f1348707..ed95344a2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt @@ -1555,6 +1555,8 @@ private constructor( @JvmField val COLLECTION = of("COLLECTION") + @JvmField val BANK_ACCOUNTS_PAYABLE = of("BANK_ACCOUNTS_PAYABLE") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -1569,6 +1571,7 @@ private constructor( SECURITY, PROGRAM_RECEIVABLES, COLLECTION, + BANK_ACCOUNTS_PAYABLE, } /** @@ -1590,6 +1593,7 @@ private constructor( SECURITY, PROGRAM_RECEIVABLES, COLLECTION, + BANK_ACCOUNTS_PAYABLE, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1612,6 +1616,7 @@ private constructor( SECURITY -> Value.SECURITY PROGRAM_RECEIVABLES -> Value.PROGRAM_RECEIVABLES COLLECTION -> Value.COLLECTION + BANK_ACCOUNTS_PAYABLE -> Value.BANK_ACCOUNTS_PAYABLE else -> Value._UNKNOWN } @@ -1635,6 +1640,7 @@ private constructor( SECURITY -> Known.SECURITY PROGRAM_RECEIVABLES -> Known.PROGRAM_RECEIVABLES COLLECTION -> Known.COLLECTION + BANK_ACCOUNTS_PAYABLE -> Known.BANK_ACCOUNTS_PAYABLE else -> throw LithicInvalidDataException("Unknown Type: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt index c0991d9b2..adefc490f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt @@ -752,6 +752,7 @@ private constructor( override fun toString() = value.toString() } + /** Financial Event */ class FinancialEvent private constructor( private val token: JsonField, diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt index 5310cfd9c..3b13057a6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt @@ -41,6 +41,8 @@ private constructor(private val value: JsonField) : Enum { @JvmField val COLLECTION = of("COLLECTION") + @JvmField val BANK_ACCOUNTS_PAYABLE = of("BANK_ACCOUNTS_PAYABLE") + @JvmStatic fun of(value: String) = InstanceFinancialAccountType(JsonField.of(value)) } @@ -55,6 +57,7 @@ private constructor(private val value: JsonField) : Enum { SECURITY, PROGRAM_RECEIVABLES, COLLECTION, + BANK_ACCOUNTS_PAYABLE, } /** @@ -78,6 +81,7 @@ private constructor(private val value: JsonField) : Enum { SECURITY, PROGRAM_RECEIVABLES, COLLECTION, + BANK_ACCOUNTS_PAYABLE, /** * An enum member indicating that [InstanceFinancialAccountType] was instantiated with an * unknown value. @@ -103,6 +107,7 @@ private constructor(private val value: JsonField) : Enum { SECURITY -> Value.SECURITY PROGRAM_RECEIVABLES -> Value.PROGRAM_RECEIVABLES COLLECTION -> Value.COLLECTION + BANK_ACCOUNTS_PAYABLE -> Value.BANK_ACCOUNTS_PAYABLE else -> Value._UNKNOWN } @@ -125,6 +130,7 @@ private constructor(private val value: JsonField) : Enum { SECURITY -> Known.SECURITY PROGRAM_RECEIVABLES -> Known.PROGRAM_RECEIVABLES COLLECTION -> Known.COLLECTION + BANK_ACCOUNTS_PAYABLE -> Known.BANK_ACCOUNTS_PAYABLE else -> throw LithicInvalidDataException("Unknown InstanceFinancialAccountType: $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 ba570293b..f4ac4ff72 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 @@ -44,6 +44,7 @@ private constructor( private val updated: JsonField, private val userDefinedId: JsonField, private val expectedReleaseDate: JsonField, + private val type: JsonField, private val additionalProperties: MutableMap, ) { @@ -95,6 +96,7 @@ private constructor( @JsonProperty("expected_release_date") @ExcludeMissing expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this( token, category, @@ -116,6 +118,7 @@ private constructor( updated, userDefinedId, expectedReleaseDate, + type, mutableMapOf(), ) @@ -277,6 +280,14 @@ private constructor( fun expectedReleaseDate(): Optional = expectedReleaseDate.getOptional("expected_release_date") + /** + * Payment type indicating the specific ACH message or Fedwire transfer type + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + /** * Returns the raw JSON value of [token]. * @@ -438,6 +449,13 @@ private constructor( @ExcludeMissing fun _expectedReleaseDate(): JsonField = expectedReleaseDate + /** + * 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) @@ -504,6 +522,7 @@ private constructor( private var updated: JsonField? = null private var userDefinedId: JsonField? = null private var expectedReleaseDate: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -528,6 +547,7 @@ private constructor( updated = payment.updated userDefinedId = payment.userDefinedId expectedReleaseDate = payment.expectedReleaseDate + type = payment.type additionalProperties = payment.additionalProperties.toMutableMap() } @@ -823,6 +843,18 @@ private constructor( this.expectedReleaseDate = expectedReleaseDate } + /** Payment type indicating the specific ACH message or Fedwire transfer type */ + fun type(type: TransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [TransferType] 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) @@ -894,6 +926,7 @@ private constructor( checkRequired("updated", updated), checkRequired("userDefinedId", userDefinedId), expectedReleaseDate, + type, additionalProperties.toMutableMap(), ) } @@ -925,6 +958,7 @@ private constructor( updated() userDefinedId() expectedReleaseDate() + type().ifPresent { it.validate() } validated = true } @@ -962,7 +996,8 @@ private constructor( (status.asKnown().getOrNull()?.validity() ?: 0) + (if (updated.asKnown().isPresent) 1 else 0) + (if (userDefinedId.asKnown().isPresent) 1 else 0) + - (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) /** Payment category */ class Category @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1211,13 +1246,14 @@ private constructor( override fun toString() = value.toString() } + /** Payment Event */ class PaymentEvent private constructor( private val token: JsonField, private val amount: JsonField, private val created: JsonField, private val result: JsonField, - private val type: JsonField, + private val type: JsonField, private val detailedResults: JsonField>, private val additionalProperties: MutableMap, ) { @@ -1230,9 +1266,7 @@ private constructor( @ExcludeMissing created: JsonField = JsonMissing.of(), @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("detailed_results") @ExcludeMissing detailedResults: JsonField> = JsonMissing.of(), @@ -1295,7 +1329,7 @@ private constructor( * @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(): PaymentEventType = type.getRequired("type") + fun type(): Type = type.getRequired("type") /** * More detailed reasons for the event @@ -1339,7 +1373,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [detailedResults]. @@ -1387,7 +1421,7 @@ private constructor( private var amount: JsonField? = null private var created: JsonField? = null private var result: JsonField? = null - private var type: JsonField? = null + private var type: JsonField? = null private var detailedResults: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -1476,16 +1510,16 @@ private constructor( * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository * Financial Institution. */ - fun type(type: PaymentEventType) = type(JsonField.of(type)) + fun type(type: Type) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [PaymentEventType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** More detailed reasons for the event */ fun detailedResults(detailedResults: List) = @@ -1753,9 +1787,7 @@ private constructor( * - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository Financial * Institution. */ - class PaymentEventType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1791,10 +1823,10 @@ private constructor( @JvmField val ACH_RETURN_SETTLED = of("ACH_RETURN_SETTLED") - @JvmStatic fun of(value: String) = PaymentEventType(JsonField.of(value)) + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - /** An enum containing [PaymentEventType]'s known values. */ + /** An enum containing [Type]'s known values. */ enum class Known { ACH_ORIGINATION_CANCELLED, ACH_ORIGINATION_INITIATED, @@ -1810,10 +1842,9 @@ private constructor( } /** - * An enum containing [PaymentEventType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [PaymentEventType] can contain an unknown value in a couple of cases: + * An instance of [Type] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. @@ -1831,10 +1862,7 @@ private constructor( ACH_RETURN_INITIATED, ACH_RETURN_PROCESSED, ACH_RETURN_SETTLED, - /** - * An enum member indicating that [PaymentEventType] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1883,7 +1911,7 @@ private constructor( ACH_RETURN_INITIATED -> Known.ACH_RETURN_INITIATED ACH_RETURN_PROCESSED -> Known.ACH_RETURN_PROCESSED ACH_RETURN_SETTLED -> Known.ACH_RETURN_SETTLED - else -> throw LithicInvalidDataException("Unknown PaymentEventType: $value") + else -> throw LithicInvalidDataException("Unknown Type: $value") } /** @@ -1902,7 +1930,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PaymentEventType = apply { + fun validate(): Type = apply { if (validated) { return@apply } @@ -1932,7 +1960,7 @@ private constructor( return true } - return other is PaymentEventType && value == other.value + return other is Type && value == other.value } override fun hashCode() = value.hashCode() @@ -3468,6 +3496,183 @@ private constructor( override fun toString() = value.toString() } + /** Payment type indicating the specific ACH message or Fedwire transfer type */ + class TransferType @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 ORIGINATION_CREDIT = of("ORIGINATION_CREDIT") + + @JvmField val ORIGINATION_DEBIT = of("ORIGINATION_DEBIT") + + @JvmField val RECEIPT_CREDIT = of("RECEIPT_CREDIT") + + @JvmField val RECEIPT_DEBIT = of("RECEIPT_DEBIT") + + @JvmField val CUSTOMER_TRANSFER = of("CUSTOMER_TRANSFER") + + @JvmField val DRAWDOWN_PAYMENT = of("DRAWDOWN_PAYMENT") + + @JvmField val REVERSAL_PAYMENT = of("REVERSAL_PAYMENT") + + @JvmField val DRAWDOWN_REQUEST = of("DRAWDOWN_REQUEST") + + @JvmField val REVERSAL_REQUEST = of("REVERSAL_REQUEST") + + @JvmField val DRAWDOWN_REFUSAL = of("DRAWDOWN_REFUSAL") + + @JvmStatic fun of(value: String) = TransferType(JsonField.of(value)) + } + + /** An enum containing [TransferType]'s known values. */ + enum class Known { + ORIGINATION_CREDIT, + ORIGINATION_DEBIT, + RECEIPT_CREDIT, + RECEIPT_DEBIT, + CUSTOMER_TRANSFER, + DRAWDOWN_PAYMENT, + REVERSAL_PAYMENT, + DRAWDOWN_REQUEST, + REVERSAL_REQUEST, + DRAWDOWN_REFUSAL, + } + + /** + * An enum containing [TransferType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TransferType] 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 { + ORIGINATION_CREDIT, + ORIGINATION_DEBIT, + RECEIPT_CREDIT, + RECEIPT_DEBIT, + CUSTOMER_TRANSFER, + DRAWDOWN_PAYMENT, + REVERSAL_PAYMENT, + DRAWDOWN_REQUEST, + REVERSAL_REQUEST, + DRAWDOWN_REFUSAL, + /** + * An enum member indicating that [TransferType] 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) { + ORIGINATION_CREDIT -> Value.ORIGINATION_CREDIT + ORIGINATION_DEBIT -> Value.ORIGINATION_DEBIT + RECEIPT_CREDIT -> Value.RECEIPT_CREDIT + RECEIPT_DEBIT -> Value.RECEIPT_DEBIT + CUSTOMER_TRANSFER -> Value.CUSTOMER_TRANSFER + DRAWDOWN_PAYMENT -> Value.DRAWDOWN_PAYMENT + REVERSAL_PAYMENT -> Value.REVERSAL_PAYMENT + DRAWDOWN_REQUEST -> Value.DRAWDOWN_REQUEST + REVERSAL_REQUEST -> Value.REVERSAL_REQUEST + DRAWDOWN_REFUSAL -> Value.DRAWDOWN_REFUSAL + 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) { + ORIGINATION_CREDIT -> Known.ORIGINATION_CREDIT + ORIGINATION_DEBIT -> Known.ORIGINATION_DEBIT + RECEIPT_CREDIT -> Known.RECEIPT_CREDIT + RECEIPT_DEBIT -> Known.RECEIPT_DEBIT + CUSTOMER_TRANSFER -> Known.CUSTOMER_TRANSFER + DRAWDOWN_PAYMENT -> Known.DRAWDOWN_PAYMENT + REVERSAL_PAYMENT -> Known.REVERSAL_PAYMENT + DRAWDOWN_REQUEST -> Known.DRAWDOWN_REQUEST + REVERSAL_REQUEST -> Known.REVERSAL_REQUEST + DRAWDOWN_REFUSAL -> Known.DRAWDOWN_REFUSAL + else -> throw LithicInvalidDataException("Unknown TransferType: $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(): TransferType = 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 other is TransferType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3494,6 +3699,7 @@ private constructor( updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && + type == other.type && additionalProperties == other.additionalProperties } @@ -3519,6 +3725,7 @@ private constructor( updated, userDefinedId, expectedReleaseDate, + type, additionalProperties, ) } @@ -3526,5 +3733,5 @@ private constructor( 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, relatedAccountTokens=$relatedAccountTokens, 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, type=$type, 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 bc026e69a..0379b3700 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 @@ -43,6 +43,7 @@ private constructor( private val updated: JsonField, private val userDefinedId: JsonField, private val expectedReleaseDate: JsonField, + private val type: JsonField, private val balance: JsonField, private val additionalProperties: MutableMap, ) { @@ -105,6 +106,9 @@ private constructor( @JsonProperty("expected_release_date") @ExcludeMissing expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), ) : this( token, @@ -127,6 +131,7 @@ private constructor( updated, userDefinedId, expectedReleaseDate, + type, balance, mutableMapOf(), ) @@ -153,6 +158,7 @@ private constructor( .updated(updated) .userDefinedId(userDefinedId) .expectedReleaseDate(expectedReleaseDate) + .type(type) .build() /** @@ -313,6 +319,14 @@ private constructor( fun expectedReleaseDate(): Optional = expectedReleaseDate.getOptional("expected_release_date") + /** + * Payment type indicating the specific ACH message or Fedwire transfer type + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + /** * Balance * @@ -488,6 +502,13 @@ private constructor( @ExcludeMissing fun _expectedReleaseDate(): JsonField = expectedReleaseDate + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** * Returns the raw JSON value of [balance]. * @@ -561,6 +582,7 @@ private constructor( private var updated: JsonField? = null private var userDefinedId: JsonField? = null private var expectedReleaseDate: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var balance: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -586,6 +608,7 @@ private constructor( updated = paymentCreateResponse.updated userDefinedId = paymentCreateResponse.userDefinedId expectedReleaseDate = paymentCreateResponse.expectedReleaseDate + type = paymentCreateResponse.type balance = paymentCreateResponse.balance additionalProperties = paymentCreateResponse.additionalProperties.toMutableMap() } @@ -889,6 +912,18 @@ private constructor( this.expectedReleaseDate = expectedReleaseDate } + /** Payment type indicating the specific ACH message or Fedwire transfer type */ + fun type(type: Payment.TransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Payment.TransferType] 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 } + /** Balance */ fun balance(balance: Balance) = balance(JsonField.of(balance)) @@ -971,6 +1006,7 @@ private constructor( checkRequired("updated", updated), checkRequired("userDefinedId", userDefinedId), expectedReleaseDate, + type, balance, additionalProperties.toMutableMap(), ) @@ -1003,6 +1039,7 @@ private constructor( updated() userDefinedId() expectedReleaseDate() + type().ifPresent { it.validate() } balance().ifPresent { it.validate() } validated = true } @@ -1042,6 +1079,7 @@ private constructor( (if (updated.asKnown().isPresent) 1 else 0) + (if (userDefinedId.asKnown().isPresent) 1 else 0) + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + (balance.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -1070,6 +1108,7 @@ private constructor( updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && + type == other.type && balance == other.balance && additionalProperties == other.additionalProperties } @@ -1096,6 +1135,7 @@ private constructor( updated, userDefinedId, expectedReleaseDate, + type, balance, additionalProperties, ) @@ -1104,5 +1144,5 @@ private constructor( 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, relatedAccountTokens=$relatedAccountTokens, 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, type=$type, 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 6592e40ba..593c3fafb 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 @@ -43,6 +43,7 @@ private constructor( private val updated: JsonField, private val userDefinedId: JsonField, private val expectedReleaseDate: JsonField, + private val type: JsonField, private val balance: JsonField, private val additionalProperties: MutableMap, ) { @@ -105,6 +106,9 @@ private constructor( @JsonProperty("expected_release_date") @ExcludeMissing expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), ) : this( token, @@ -127,6 +131,7 @@ private constructor( updated, userDefinedId, expectedReleaseDate, + type, balance, mutableMapOf(), ) @@ -153,6 +158,7 @@ private constructor( .updated(updated) .userDefinedId(userDefinedId) .expectedReleaseDate(expectedReleaseDate) + .type(type) .build() /** @@ -313,6 +319,14 @@ private constructor( fun expectedReleaseDate(): Optional = expectedReleaseDate.getOptional("expected_release_date") + /** + * Payment type indicating the specific ACH message or Fedwire transfer type + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + /** * Balance * @@ -488,6 +502,13 @@ private constructor( @ExcludeMissing fun _expectedReleaseDate(): JsonField = expectedReleaseDate + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** * Returns the raw JSON value of [balance]. * @@ -561,6 +582,7 @@ private constructor( private var updated: JsonField? = null private var userDefinedId: JsonField? = null private var expectedReleaseDate: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var balance: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -586,6 +608,7 @@ private constructor( updated = paymentRetryResponse.updated userDefinedId = paymentRetryResponse.userDefinedId expectedReleaseDate = paymentRetryResponse.expectedReleaseDate + type = paymentRetryResponse.type balance = paymentRetryResponse.balance additionalProperties = paymentRetryResponse.additionalProperties.toMutableMap() } @@ -889,6 +912,18 @@ private constructor( this.expectedReleaseDate = expectedReleaseDate } + /** Payment type indicating the specific ACH message or Fedwire transfer type */ + fun type(type: Payment.TransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Payment.TransferType] 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 } + /** Balance */ fun balance(balance: Balance) = balance(JsonField.of(balance)) @@ -971,6 +1006,7 @@ private constructor( checkRequired("updated", updated), checkRequired("userDefinedId", userDefinedId), expectedReleaseDate, + type, balance, additionalProperties.toMutableMap(), ) @@ -1003,6 +1039,7 @@ private constructor( updated() userDefinedId() expectedReleaseDate() + type().ifPresent { it.validate() } balance().ifPresent { it.validate() } validated = true } @@ -1042,6 +1079,7 @@ private constructor( (if (updated.asKnown().isPresent) 1 else 0) + (if (userDefinedId.asKnown().isPresent) 1 else 0) + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + (balance.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -1070,6 +1108,7 @@ private constructor( updated == other.updated && userDefinedId == other.userDefinedId && expectedReleaseDate == other.expectedReleaseDate && + type == other.type && balance == other.balance && additionalProperties == other.additionalProperties } @@ -1096,6 +1135,7 @@ private constructor( updated, userDefinedId, expectedReleaseDate, + type, balance, additionalProperties, ) @@ -1104,5 +1144,5 @@ private constructor( 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, relatedAccountTokens=$relatedAccountTokens, 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, type=$type, balance=$balance, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transfer.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transfer.kt index ad2cb8818..d2eeda223 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transfer.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transfer.kt @@ -791,6 +791,7 @@ private constructor( override fun toString() = value.toString() } + /** Financial Event */ class FinancialEvent private constructor( private val token: JsonField, 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 index 116f413d3..66224beb1 100644 --- 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 @@ -3,7 +3,6 @@ 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 @@ -25,7 +24,24 @@ internal class AccountActivityListPageResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .Result + .APPROVED + ) + .type( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes .CARD @@ -58,7 +74,24 @@ internal class AccountActivityListPageResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .Result + .APPROVED + ) + .type( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes .CARD @@ -95,7 +128,24 @@ internal class AccountActivityListPageResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .Result + .APPROVED + ) + .type( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes .CARD 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 index 900db4ba1..fe14ce921 100644 --- 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 @@ -12,6 +12,7 @@ internal class AccountActivityListParamsTest { @Test fun create() { AccountActivityListParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .category(AccountActivityListParams.TransactionCategory.ACH) @@ -29,6 +30,7 @@ internal class AccountActivityListParamsTest { fun queryParams() { val params = AccountActivityListParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .category(AccountActivityListParams.TransactionCategory.ACH) @@ -46,6 +48,7 @@ internal class AccountActivityListParamsTest { assertThat(queryParams) .isEqualTo( QueryParams.builder() + .put("account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .put("begin", "2019-12-27T18:11:19.117Z") .put("business_account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .put("category", "ACH") 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 index 03158aa1d..f093621cb 100644 --- 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 @@ -25,7 +25,22 @@ internal class AccountActivityListResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.FinancialTransaction.FinancialEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.FinancialTransaction.FinancialEvent.Result + .APPROVED + ) + .type( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes.CARD ) @@ -62,7 +77,23 @@ internal class AccountActivityListResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.FinancialTransaction.FinancialEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .Result + .APPROVED + ) + .type( + AccountActivityListResponse.FinancialTransaction.FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityListResponse.FinancialTransaction.TransactionFamilyTypes.CARD ) @@ -98,7 +129,30 @@ internal class AccountActivityListResponseTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.BookTransferTransaction.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .detailedResults( + AccountActivityListResponse.BookTransferTransaction.BookTransferEvent + .BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result( + AccountActivityListResponse.BookTransferTransaction.BookTransferEvent + .Result + .APPROVED + ) + .subtype("subtype") + .type( + AccountActivityListResponse.BookTransferTransaction.BookTransferEvent + .BookTransferType + .ATM_WITHDRAWAL + ) + .build() + ) .family( AccountActivityListResponse.BookTransferTransaction.TransactionFamilyTypes.CARD ) @@ -154,7 +208,34 @@ internal class AccountActivityListResponseTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.BookTransferTransaction.BookTransferEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .detailedResults( + AccountActivityListResponse.BookTransferTransaction + .BookTransferEvent + .BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result( + AccountActivityListResponse.BookTransferTransaction + .BookTransferEvent + .Result + .APPROVED + ) + .subtype("subtype") + .type( + AccountActivityListResponse.BookTransferTransaction + .BookTransferEvent + .BookTransferType + .ATM_WITHDRAWAL + ) + .build() + ) .family( AccountActivityListResponse.BookTransferTransaction.TransactionFamilyTypes .CARD @@ -711,7 +792,26 @@ internal class AccountActivityListResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .descriptor("descriptor") .direction(AccountActivityListResponse.PaymentTransaction.Direction.CREDIT) - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.PaymentTransaction.PaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.PaymentTransaction.PaymentEvent.Result + .APPROVED + ) + .type( + AccountActivityListResponse.PaymentTransaction.PaymentEvent.Type + .ACH_ORIGINATION_CANCELLED + ) + .addDetailedResult( + AccountActivityListResponse.PaymentTransaction.PaymentEvent + .DetailedResult + .APPROVED + ) + .build() + ) .family(AccountActivityListResponse.PaymentTransaction.TransactionFamilyTypes.CARD) .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .method(AccountActivityListResponse.PaymentTransaction.Method.ACH_NEXT_DAY) @@ -775,7 +875,26 @@ internal class AccountActivityListResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .descriptor("descriptor") .direction(AccountActivityListResponse.PaymentTransaction.Direction.CREDIT) - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityListResponse.PaymentTransaction.PaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityListResponse.PaymentTransaction.PaymentEvent.Result + .APPROVED + ) + .type( + AccountActivityListResponse.PaymentTransaction.PaymentEvent.Type + .ACH_ORIGINATION_CANCELLED + ) + .addDetailedResult( + AccountActivityListResponse.PaymentTransaction.PaymentEvent + .DetailedResult + .APPROVED + ) + .build() + ) .family( AccountActivityListResponse.PaymentTransaction.TransactionFamilyTypes.CARD ) 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 index c213323fd..e8a4c3bea 100644 --- 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 @@ -29,7 +29,26 @@ internal class AccountActivityRetrieveTransactionResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityRetrieveTransactionResponse.FinancialTransaction.FinancialEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .FinancialEvent + .Result + .APPROVED + ) + .type( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityRetrieveTransactionResponse.FinancialTransaction .TransactionFamilyTypes @@ -79,7 +98,27 @@ internal class AccountActivityRetrieveTransactionResponseTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .descriptor("descriptor") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .FinancialEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .FinancialEvent + .Result + .APPROVED + ) + .type( + AccountActivityRetrieveTransactionResponse.FinancialTransaction + .FinancialEvent + .FinancialEventType + .ACH_ORIGINATION_CANCELLED + ) + .build() + ) .family( AccountActivityRetrieveTransactionResponse.FinancialTransaction .TransactionFamilyTypes @@ -124,7 +163,35 @@ internal class AccountActivityRetrieveTransactionResponseTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .detailedResults( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .Result + .APPROVED + ) + .subtype("subtype") + .type( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .BookTransferType + .ATM_WITHDRAWAL + ) + .build() + ) .family( AccountActivityRetrieveTransactionResponse.BookTransferTransaction .TransactionFamilyTypes @@ -193,7 +260,35 @@ internal class AccountActivityRetrieveTransactionResponseTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .detailedResults( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .Result + .APPROVED + ) + .subtype("subtype") + .type( + AccountActivityRetrieveTransactionResponse.BookTransferTransaction + .BookTransferEvent + .BookTransferType + .ATM_WITHDRAWAL + ) + .build() + ) .family( AccountActivityRetrieveTransactionResponse.BookTransferTransaction .TransactionFamilyTypes @@ -772,7 +867,32 @@ internal class AccountActivityRetrieveTransactionResponseTest { .direction( AccountActivityRetrieveTransactionResponse.PaymentTransaction.Direction.CREDIT ) - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.PaymentEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .PaymentEvent + .Result + .APPROVED + ) + .type( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .PaymentEvent + .Type + .ACH_ORIGINATION_CANCELLED + ) + .addDetailedResult( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .PaymentEvent + .DetailedResult + .APPROVED + ) + .build() + ) .family( AccountActivityRetrieveTransactionResponse.PaymentTransaction .TransactionFamilyTypes @@ -859,7 +979,32 @@ internal class AccountActivityRetrieveTransactionResponseTest { AccountActivityRetrieveTransactionResponse.PaymentTransaction.Direction .CREDIT ) - .addEvent(JsonValue.from(mapOf())) + .addEvent( + AccountActivityRetrieveTransactionResponse.PaymentTransaction.PaymentEvent + .builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .PaymentEvent + .Result + .APPROVED + ) + .type( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .PaymentEvent + .Type + .ACH_ORIGINATION_CANCELLED + ) + .addDetailedResult( + AccountActivityRetrieveTransactionResponse.PaymentTransaction + .PaymentEvent + .DetailedResult + .APPROVED + ) + .build() + ) .family( AccountActivityRetrieveTransactionResponse.PaymentTransaction .TransactionFamilyTypes diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferCreateParamsTest.kt index 5562e8600..80adc0934 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferCreateParamsTest.kt @@ -11,13 +11,15 @@ internal class BookTransferCreateParamsTest { fun create() { BookTransferCreateParams.builder() .amount(1L) - .category(BookTransferCreateParams.Category.ADJUSTMENT) + .category(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .subtype("subtype") .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .type(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + .type(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .externalId("external_id") .memo("memo") + .onClosedAccount(BookTransferCreateParams.OnClosedAccount.FAIL) .build() } @@ -26,26 +28,31 @@ internal class BookTransferCreateParamsTest { val params = BookTransferCreateParams.builder() .amount(1L) - .category(BookTransferCreateParams.Category.ADJUSTMENT) + .category(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .subtype("subtype") .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .type(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + .type(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .externalId("external_id") .memo("memo") + .onClosedAccount(BookTransferCreateParams.OnClosedAccount.FAIL) .build() val body = params._body() assertThat(body.amount()).isEqualTo(1L) - assertThat(body.category()).isEqualTo(BookTransferCreateParams.Category.ADJUSTMENT) + assertThat(body.category()) + .isEqualTo(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) assertThat(body.fromFinancialAccountToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.subtype()).isEqualTo("subtype") assertThat(body.toFinancialAccountToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.type()).isEqualTo(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + assertThat(body.type()).isEqualTo(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) assertThat(body.token()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.externalId()).contains("external_id") assertThat(body.memo()).contains("memo") + assertThat(body.onClosedAccount()).contains(BookTransferCreateParams.OnClosedAccount.FAIL) } @Test @@ -53,21 +60,22 @@ internal class BookTransferCreateParamsTest { val params = BookTransferCreateParams.builder() .amount(1L) - .category(BookTransferCreateParams.Category.ADJUSTMENT) + .category(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .subtype("subtype") .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .type(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + .type(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) .build() val body = params._body() assertThat(body.amount()).isEqualTo(1L) - assertThat(body.category()).isEqualTo(BookTransferCreateParams.Category.ADJUSTMENT) + assertThat(body.category()) + .isEqualTo(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) assertThat(body.fromFinancialAccountToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.subtype()).isEqualTo("subtype") assertThat(body.toFinancialAccountToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.type()).isEqualTo(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + assertThat(body.type()).isEqualTo(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) } } 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 1d4d12296..7134349b9 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 @@ -3,7 +3,6 @@ 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 org.assertj.core.api.Assertions.assertThat @@ -18,7 +17,7 @@ internal class BookTransferListPageResponseTest { .addData( BookTransferResponse.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .category(BookTransferResponse.Category.ADJUSTMENT) + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .addEvent( @@ -26,15 +25,21 @@ internal class BookTransferListPageResponseTest { .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addDetailedResult( - BookTransferResponse.BookTransferEvent.DetailedResult.APPROVED + .detailedResults( + BookTransferResponse.BookTransferEvent + .BookTransferDetailedResults + .APPROVED ) .memo("memo") .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) .subtype("subtype") - .type("type") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_WITHDRAWAL + ) .build() ) + .externalId("external_id") .externalResource( ExternalResource.builder() .externalResourceToken("external_resource_token") @@ -44,10 +49,10 @@ internal class BookTransferListPageResponseTest { ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) - .result(BookTransferResponse.Result.APPROVED) + .result(BookTransferResponse.TransactionResult.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) - .toFinancialAccountToken(JsonValue.from(mapOf())) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .transactionSeries( BookTransferResponse.TransactionSeries.builder() .relatedTransactionEventToken( @@ -67,7 +72,7 @@ internal class BookTransferListPageResponseTest { .containsExactly( BookTransferResponse.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .category(BookTransferResponse.Category.ADJUSTMENT) + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .addEvent( @@ -75,15 +80,20 @@ internal class BookTransferListPageResponseTest { .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addDetailedResult( - BookTransferResponse.BookTransferEvent.DetailedResult.APPROVED + .detailedResults( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED ) .memo("memo") .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) .subtype("subtype") - .type("type") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_WITHDRAWAL + ) .build() ) + .externalId("external_id") .externalResource( ExternalResource.builder() .externalResourceToken("external_resource_token") @@ -93,10 +103,10 @@ internal class BookTransferListPageResponseTest { ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) - .result(BookTransferResponse.Result.APPROVED) + .result(BookTransferResponse.TransactionResult.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) - .toFinancialAccountToken(JsonValue.from(mapOf())) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .transactionSeries( BookTransferResponse.TransactionSeries.builder() .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") @@ -118,7 +128,7 @@ internal class BookTransferListPageResponseTest { .addData( BookTransferResponse.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .category(BookTransferResponse.Category.ADJUSTMENT) + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .addEvent( @@ -126,15 +136,21 @@ internal class BookTransferListPageResponseTest { .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addDetailedResult( - BookTransferResponse.BookTransferEvent.DetailedResult.APPROVED + .detailedResults( + BookTransferResponse.BookTransferEvent + .BookTransferDetailedResults + .APPROVED ) .memo("memo") .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) .subtype("subtype") - .type("type") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_WITHDRAWAL + ) .build() ) + .externalId("external_id") .externalResource( ExternalResource.builder() .externalResourceToken("external_resource_token") @@ -144,10 +160,10 @@ internal class BookTransferListPageResponseTest { ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) - .result(BookTransferResponse.Result.APPROVED) + .result(BookTransferResponse.TransactionResult.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) - .toFinancialAccountToken(JsonValue.from(mapOf())) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .transactionSeries( BookTransferResponse.TransactionSeries.builder() .relatedTransactionEventToken( 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 c271e6c35..45eb53867 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 @@ -3,7 +3,6 @@ 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 org.assertj.core.api.Assertions.assertThat @@ -16,7 +15,7 @@ internal class BookTransferResponseTest { val bookTransferResponse = BookTransferResponse.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .category(BookTransferResponse.Category.ADJUSTMENT) + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .addEvent( @@ -24,15 +23,19 @@ internal class BookTransferResponseTest { .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addDetailedResult( - BookTransferResponse.BookTransferEvent.DetailedResult.APPROVED + .detailedResults( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED ) .memo("memo") .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) .subtype("subtype") - .type("type") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType.ATM_WITHDRAWAL + ) .build() ) + .externalId("external_id") .externalResource( ExternalResource.builder() .externalResourceToken("external_resource_token") @@ -42,10 +45,10 @@ internal class BookTransferResponseTest { ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) - .result(BookTransferResponse.Result.APPROVED) + .result(BookTransferResponse.TransactionResult.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) - .toFinancialAccountToken(JsonValue.from(mapOf())) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .transactionSeries( BookTransferResponse.TransactionSeries.builder() .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") @@ -58,7 +61,7 @@ internal class BookTransferResponseTest { assertThat(bookTransferResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(bookTransferResponse.category()) - .isEqualTo(BookTransferResponse.Category.ADJUSTMENT) + .isEqualTo(BookTransferResponse.BookTransferCategory.ADJUSTMENT) assertThat(bookTransferResponse.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(bookTransferResponse.currency()).isEqualTo("currency") @@ -68,15 +71,16 @@ internal class BookTransferResponseTest { .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addDetailedResult( - BookTransferResponse.BookTransferEvent.DetailedResult.APPROVED + .detailedResults( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults.APPROVED ) .memo("memo") .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) .subtype("subtype") - .type("type") + .type(BookTransferResponse.BookTransferEvent.BookTransferType.ATM_WITHDRAWAL) .build() ) + assertThat(bookTransferResponse.externalId()).contains("external_id") assertThat(bookTransferResponse.externalResource()) .contains( ExternalResource.builder() @@ -88,11 +92,12 @@ internal class BookTransferResponseTest { assertThat(bookTransferResponse.fromFinancialAccountToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(bookTransferResponse.pendingAmount()).isEqualTo(0L) - assertThat(bookTransferResponse.result()).isEqualTo(BookTransferResponse.Result.APPROVED) + assertThat(bookTransferResponse.result()) + .isEqualTo(BookTransferResponse.TransactionResult.APPROVED) assertThat(bookTransferResponse.settledAmount()).isEqualTo(0L) assertThat(bookTransferResponse.status()).isEqualTo(BookTransferResponse.Status.DECLINED) - assertThat(bookTransferResponse._toFinancialAccountToken()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(bookTransferResponse.toFinancialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(bookTransferResponse.transactionSeries()) .contains( BookTransferResponse.TransactionSeries.builder() @@ -111,7 +116,7 @@ internal class BookTransferResponseTest { val bookTransferResponse = BookTransferResponse.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .category(BookTransferResponse.Category.ADJUSTMENT) + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .addEvent( @@ -119,15 +124,19 @@ internal class BookTransferResponseTest { .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addDetailedResult( - BookTransferResponse.BookTransferEvent.DetailedResult.APPROVED + .detailedResults( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED ) .memo("memo") .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) .subtype("subtype") - .type("type") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType.ATM_WITHDRAWAL + ) .build() ) + .externalId("external_id") .externalResource( ExternalResource.builder() .externalResourceToken("external_resource_token") @@ -137,10 +146,10 @@ internal class BookTransferResponseTest { ) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) - .result(BookTransferResponse.Result.APPROVED) + .result(BookTransferResponse.TransactionResult.APPROVED) .settledAmount(0L) .status(BookTransferResponse.Status.DECLINED) - .toFinancialAccountToken(JsonValue.from(mapOf())) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .transactionSeries( BookTransferResponse.TransactionSeries.builder() .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") 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 f7adb8d42..d27739de5 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 @@ -27,7 +27,7 @@ internal class PaymentCreateResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -59,6 +59,7 @@ internal class PaymentCreateResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .balance( Balance.builder() .availableAmount(0L) @@ -89,7 +90,7 @@ internal class PaymentCreateResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -127,6 +128,7 @@ internal class PaymentCreateResponseTest { assertThat(paymentCreateResponse.userDefinedId()).contains("user_defined_id") assertThat(paymentCreateResponse.expectedReleaseDate()) .contains(LocalDate.parse("2019-12-27")) + assertThat(paymentCreateResponse.type()).contains(Payment.TransferType.ORIGINATION_CREDIT) assertThat(paymentCreateResponse.balance()) .contains( Balance.builder() @@ -161,7 +163,7 @@ internal class PaymentCreateResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -193,6 +195,7 @@ internal class PaymentCreateResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .balance( Balance.builder() .availableAmount(0L) 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 b2d38f636..a6941305d 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 @@ -29,9 +29,7 @@ internal class PaymentListPageResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type( - Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED - ) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -63,6 +61,7 @@ internal class PaymentListPageResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .build() ) .hasMore(true) @@ -83,7 +82,7 @@ internal class PaymentListPageResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -115,6 +114,7 @@ internal class PaymentListPageResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .build() ) assertThat(paymentListPageResponse.hasMore()).isEqualTo(true) @@ -139,9 +139,7 @@ internal class PaymentListPageResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type( - Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED - ) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -173,6 +171,7 @@ internal class PaymentListPageResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .build() ) .hasMore(true) 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 14f4cfb19..1a1e87dad 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 @@ -27,7 +27,7 @@ internal class PaymentRetryResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -59,6 +59,7 @@ internal class PaymentRetryResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .balance( Balance.builder() .availableAmount(0L) @@ -89,7 +90,7 @@ internal class PaymentRetryResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -127,6 +128,7 @@ internal class PaymentRetryResponseTest { assertThat(paymentRetryResponse.userDefinedId()).contains("user_defined_id") assertThat(paymentRetryResponse.expectedReleaseDate()) .contains(LocalDate.parse("2019-12-27")) + assertThat(paymentRetryResponse.type()).contains(Payment.TransferType.ORIGINATION_CREDIT) assertThat(paymentRetryResponse.balance()) .contains( Balance.builder() @@ -161,7 +163,7 @@ internal class PaymentRetryResponseTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -193,6 +195,7 @@ internal class PaymentRetryResponseTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .balance( Balance.builder() .availableAmount(0L) 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 e7be3586a..bc488895d 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 @@ -27,7 +27,7 @@ internal class PaymentTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -59,6 +59,7 @@ internal class PaymentTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .build() assertThat(payment.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -74,7 +75,7 @@ internal class PaymentTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -110,6 +111,7 @@ internal class PaymentTest { assertThat(payment.updated()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(payment.userDefinedId()).contains("user_defined_id") assertThat(payment.expectedReleaseDate()).contains(LocalDate.parse("2019-12-27")) + assertThat(payment.type()).contains(Payment.TransferType.ORIGINATION_CREDIT) } @Test @@ -129,7 +131,7 @@ internal class PaymentTest { .amount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Payment.PaymentEvent.Result.APPROVED) - .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_CANCELLED) + .type(Payment.PaymentEvent.Type.ACH_ORIGINATION_CANCELLED) .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) .build() ) @@ -161,6 +163,7 @@ internal class PaymentTest { .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .userDefinedId("user_defined_id") .expectedReleaseDate(LocalDate.parse("2019-12-27")) + .type(Payment.TransferType.ORIGINATION_CREDIT) .build() val roundtrippedPayment = diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncTest.kt index 1dc466f4d..05200013a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/BookTransferServiceAsyncTest.kt @@ -25,13 +25,15 @@ internal class BookTransferServiceAsyncTest { bookTransferServiceAsync.create( BookTransferCreateParams.builder() .amount(1L) - .category(BookTransferCreateParams.Category.ADJUSTMENT) + .category(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .subtype("subtype") .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .type(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + .type(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .externalId("external_id") .memo("memo") + .onClosedAccount(BookTransferCreateParams.OnClosedAccount.FAIL) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/BookTransferServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/BookTransferServiceTest.kt index cf4a2b202..6c5a4b0e6 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/BookTransferServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/BookTransferServiceTest.kt @@ -25,13 +25,15 @@ internal class BookTransferServiceTest { bookTransferService.create( BookTransferCreateParams.builder() .amount(1L) - .category(BookTransferCreateParams.Category.ADJUSTMENT) + .category(BookTransferCreateParams.BookTransferCategory.ADJUSTMENT) .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .subtype("subtype") .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .type(BookTransferCreateParams.Type.ATM_WITHDRAWAL) + .type(BookTransferCreateParams.BookTransferType.ATM_WITHDRAWAL) .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .externalId("external_id") .memo("memo") + .onClosedAccount(BookTransferCreateParams.OnClosedAccount.FAIL) .build() ) diff --git a/scripts/build b/scripts/build new file mode 100755 index 000000000..f40634826 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/format b/scripts/format index 456a69db9..7c0be4d57 100755 --- a/scripts/format +++ b/scripts/format @@ -4,5 +4,5 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running spotlessApply" -./gradlew spotlessApply +echo "==> Running formatters" +./gradlew format diff --git a/scripts/lint b/scripts/lint index e3a5f5e24..aea8af713 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,5 +4,5 @@ set -e cd "$(dirname "$0")/.." -echo "==> Build classes" -./gradlew build testClasses -x test +echo "==> Running lints" +./gradlew lint