diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 906878cb..dac8da6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,10 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -34,7 +34,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 - name: Run lints run: ./scripts/lint @@ -49,10 +49,10 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -61,7 +61,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 - name: Build SDK run: ./scripts/build @@ -71,7 +71,7 @@ jobs: github.repository == 'stainless-sdks/lithic-java' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -91,10 +91,10 @@ jobs: 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@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -103,7 +103,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 - name: Run tests run: ./scripts/test diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 68a62dbb..6d4b3b1d 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -26,7 +26,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 - name: Publish to Sonatype run: |- diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 8cee1761..627c2555 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'lithic-com/lithic-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f38100a4..47775e91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.126.0" + ".": "0.127.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 9a940850..b5b02fac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 193 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-00f07b0edcc0c3c5ef79920ced7f58dac2434df5e4c27ff6041783e8228315f9.yml -openapi_spec_hash: 963688b09480159a06865075c94a2577 -config_hash: 265a2b679964f4ad5706de101ad2a942 +configured_endpoints: 194 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-19240135588c2012b39cde86218a05c471b3e7831b57c736704e3fbca109e3a9.yml +openapi_spec_hash: c6a5c719b89e08de52aea005b39fd5a6 +config_hash: 1c5c139a2aa0d1d45c063f953a9bc803 diff --git a/CHANGELOG.md b/CHANGELOG.md index e1207996..a89a88de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.127.0 (2026-05-15) + +Full Changelog: [v0.126.0...v0.127.0](https://github.com/lithic-com/lithic-java/compare/v0.126.0...v0.127.0) + +### Features + +* **api:** add card authorization challenge webhook, rename types in authorization models ([295e9f3](https://github.com/lithic-com/lithic-java/commit/295e9f3ce7a09c03f9c31b490f9b176d16c9194a)) + + +### Bug Fixes + +* **types:** change number from Long to Double in ConditionalValue and conditional actions ([57b5b27](https://github.com/lithic-com/lithic-java/commit/57b5b279f5c23550dbc40946227d483410ca0c14)) + ## 0.126.0 (2026-05-08) Full Changelog: [v0.125.0...v0.126.0](https://github.com/lithic-com/lithic-java/compare/v0.125.0...v0.126.0) diff --git a/README.md b/README.md index 251eadd5..e4c826c5 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.126.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.126.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.126.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.127.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.127.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.127.0) @@ -22,7 +22,7 @@ Use the Lithic MCP Server to enable AI assistants to interact with this API, all -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.126.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.127.0). @@ -33,7 +33,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.126.0") +implementation("com.lithic.api:lithic-java:0.127.0") ``` ### Maven @@ -42,7 +42,7 @@ implementation("com.lithic.api:lithic-java:0.126.0") com.lithic.api lithic-java - 0.126.0 + 0.127.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 4b8f86ba..86353f33 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.126.0" // x-release-please-version + version = "0.127.0" // x-release-please-version } subprojects { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt index 6dd840a3..4a24821c 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt @@ -15,6 +15,7 @@ import com.lithic.api.services.blocking.AuthRuleService import com.lithic.api.services.blocking.AuthStreamEnrollmentService import com.lithic.api.services.blocking.BalanceService import com.lithic.api.services.blocking.BookTransferService +import com.lithic.api.services.blocking.CardAuthorizationService import com.lithic.api.services.blocking.CardBulkOrderService import com.lithic.api.services.blocking.CardProgramService import com.lithic.api.services.blocking.CardService @@ -94,6 +95,8 @@ interface LithicClient { fun cards(): CardService + fun cardAuthorizations(): CardAuthorizationService + fun cardBulkOrders(): CardBulkOrderService fun balances(): BalanceService @@ -202,6 +205,8 @@ interface LithicClient { fun cards(): CardService.WithRawResponse + fun cardAuthorizations(): CardAuthorizationService.WithRawResponse + fun cardBulkOrders(): CardBulkOrderService.WithRawResponse fun balances(): BalanceService.WithRawResponse diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt index d5ee8d11..5949ef13 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt @@ -14,6 +14,7 @@ import com.lithic.api.services.async.AuthRuleServiceAsync import com.lithic.api.services.async.AuthStreamEnrollmentServiceAsync import com.lithic.api.services.async.BalanceServiceAsync import com.lithic.api.services.async.BookTransferServiceAsync +import com.lithic.api.services.async.CardAuthorizationServiceAsync import com.lithic.api.services.async.CardBulkOrderServiceAsync import com.lithic.api.services.async.CardProgramServiceAsync import com.lithic.api.services.async.CardServiceAsync @@ -94,6 +95,8 @@ interface LithicClientAsync { fun cards(): CardServiceAsync + fun cardAuthorizations(): CardAuthorizationServiceAsync + fun cardBulkOrders(): CardBulkOrderServiceAsync fun balances(): BalanceServiceAsync @@ -205,6 +208,8 @@ interface LithicClientAsync { fun cards(): CardServiceAsync.WithRawResponse + fun cardAuthorizations(): CardAuthorizationServiceAsync.WithRawResponse + fun cardBulkOrders(): CardBulkOrderServiceAsync.WithRawResponse fun balances(): BalanceServiceAsync.WithRawResponse diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt index 97d63df6..5b72a4d0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt @@ -31,6 +31,8 @@ import com.lithic.api.services.async.BalanceServiceAsync import com.lithic.api.services.async.BalanceServiceAsyncImpl import com.lithic.api.services.async.BookTransferServiceAsync import com.lithic.api.services.async.BookTransferServiceAsyncImpl +import com.lithic.api.services.async.CardAuthorizationServiceAsync +import com.lithic.api.services.async.CardAuthorizationServiceAsyncImpl import com.lithic.api.services.async.CardBulkOrderServiceAsync import com.lithic.api.services.async.CardBulkOrderServiceAsyncImpl import com.lithic.api.services.async.CardProgramServiceAsync @@ -131,6 +133,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl private val cards: CardServiceAsync by lazy { CardServiceAsyncImpl(clientOptionsWithUserAgent) } + private val cardAuthorizations: CardAuthorizationServiceAsync by lazy { + CardAuthorizationServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val cardBulkOrders: CardBulkOrderServiceAsync by lazy { CardBulkOrderServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -259,6 +265,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun cards(): CardServiceAsync = cards + override fun cardAuthorizations(): CardAuthorizationServiceAsync = cardAuthorizations + override fun cardBulkOrders(): CardBulkOrderServiceAsync = cardBulkOrders override fun balances(): BalanceServiceAsync = balances @@ -357,6 +365,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl CardServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardAuthorizations: CardAuthorizationServiceAsync.WithRawResponse by lazy { + CardAuthorizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val cardBulkOrders: CardBulkOrderServiceAsync.WithRawResponse by lazy { CardBulkOrderServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -488,6 +500,9 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun cards(): CardServiceAsync.WithRawResponse = cards + override fun cardAuthorizations(): CardAuthorizationServiceAsync.WithRawResponse = + cardAuthorizations + override fun cardBulkOrders(): CardBulkOrderServiceAsync.WithRawResponse = cardBulkOrders override fun balances(): BalanceServiceAsync.WithRawResponse = balances diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt index f9808009..f5fec8e1 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt @@ -31,6 +31,8 @@ import com.lithic.api.services.blocking.BalanceService import com.lithic.api.services.blocking.BalanceServiceImpl import com.lithic.api.services.blocking.BookTransferService import com.lithic.api.services.blocking.BookTransferServiceImpl +import com.lithic.api.services.blocking.CardAuthorizationService +import com.lithic.api.services.blocking.CardAuthorizationServiceImpl import com.lithic.api.services.blocking.CardBulkOrderService import com.lithic.api.services.blocking.CardBulkOrderServiceImpl import com.lithic.api.services.blocking.CardProgramService @@ -128,6 +130,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient private val cards: CardService by lazy { CardServiceImpl(clientOptionsWithUserAgent) } + private val cardAuthorizations: CardAuthorizationService by lazy { + CardAuthorizationServiceImpl(clientOptionsWithUserAgent) + } + private val cardBulkOrders: CardBulkOrderService by lazy { CardBulkOrderServiceImpl(clientOptionsWithUserAgent) } @@ -239,6 +245,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun cards(): CardService = cards + override fun cardAuthorizations(): CardAuthorizationService = cardAuthorizations + override fun cardBulkOrders(): CardBulkOrderService = cardBulkOrders override fun balances(): BalanceService = balances @@ -337,6 +345,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient CardServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardAuthorizations: CardAuthorizationService.WithRawResponse by lazy { + CardAuthorizationServiceImpl.WithRawResponseImpl(clientOptions) + } + private val cardBulkOrders: CardBulkOrderService.WithRawResponse by lazy { CardBulkOrderServiceImpl.WithRawResponseImpl(clientOptions) } @@ -468,6 +480,9 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun cards(): CardService.WithRawResponse = cards + override fun cardAuthorizations(): CardAuthorizationService.WithRawResponse = + cardAuthorizations + override fun cardBulkOrders(): CardBulkOrderService.WithRawResponse = cardBulkOrders override fun balances(): BalanceService.WithRawResponse = balances diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCondition.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCondition.kt index 24b8c8ab..ef2ed837 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCondition.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCondition.kt @@ -258,8 +258,11 @@ private constructor( /** Alias for calling [value] with `ConditionalValue.ofRegex(regex)`. */ fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ - fun value(number: Long) = value(ConditionalValue.ofNumber(number)) + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ fun valueOfListOfStrings(listOfStrings: List) = diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorization.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorization.kt new file mode 100644 index 00000000..4c4862ab --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorization.kt @@ -0,0 +1,9445 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Card Authorization */ +class CardAuthorization +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val acquirerFee: JsonField, + private val amount: JsonField, + private val amounts: JsonField, + private val authorizationAmount: JsonField, + private val avs: JsonField, + private val card: JsonField, + private val cardholderCurrency: JsonField, + private val cashAmount: JsonField, + private val created: JsonField, + private val merchant: JsonField, + private val merchantAmount: JsonField, + private val merchantCurrency: JsonField, + private val serviceLocation: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val transactionInitiator: JsonField, + private val accountType: JsonField, + private val cardholderAuthentication: JsonField, + private val cashback: JsonField, + private val conversionRate: JsonField, + private val eventToken: JsonField, + private val fleetInfo: JsonField, + private val latestChallenge: JsonField, + private val network: JsonField, + private val networkRiskScore: JsonField, + private val networkSpecificData: JsonField, + private val pos: JsonField, + private val tokenInfo: JsonField, + private val ttl: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_fee") + @ExcludeMissing + acquirerFee: 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("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), + @JsonProperty("card") @ExcludeMissing card: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_currency") + @ExcludeMissing + cardholderCurrency: JsonField = JsonMissing.of(), + @JsonProperty("cash_amount") @ExcludeMissing cashAmount: 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_currency") + @ExcludeMissing + merchantCurrency: JsonField = JsonMissing.of(), + @JsonProperty("service_location") + @ExcludeMissing + serviceLocation: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("transaction_initiator") + @ExcludeMissing + transactionInitiator: JsonField = JsonMissing.of(), + @JsonProperty("account_type") + @ExcludeMissing + accountType: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_authentication") + @ExcludeMissing + cardholderAuthentication: JsonField = JsonMissing.of(), + @JsonProperty("cashback") @ExcludeMissing cashback: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("event_token") + @ExcludeMissing + eventToken: JsonField = JsonMissing.of(), + @JsonProperty("fleet_info") + @ExcludeMissing + fleetInfo: JsonField = JsonMissing.of(), + @JsonProperty("latest_challenge") + @ExcludeMissing + latestChallenge: JsonField = JsonMissing.of(), + @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + @JsonProperty("network_risk_score") + @ExcludeMissing + networkRiskScore: JsonField = JsonMissing.of(), + @JsonProperty("network_specific_data") + @ExcludeMissing + networkSpecificData: JsonField = JsonMissing.of(), + @JsonProperty("pos") @ExcludeMissing pos: JsonField = JsonMissing.of(), + @JsonProperty("token_info") + @ExcludeMissing + tokenInfo: JsonField = JsonMissing.of(), + @JsonProperty("ttl") @ExcludeMissing ttl: JsonField = JsonMissing.of(), + ) : this( + token, + acquirerFee, + amount, + amounts, + authorizationAmount, + avs, + card, + cardholderCurrency, + cashAmount, + created, + merchant, + merchantAmount, + merchantCurrency, + serviceLocation, + settledAmount, + status, + transactionInitiator, + accountType, + cardholderAuthentication, + cashback, + conversionRate, + eventToken, + fleetInfo, + latestChallenge, + network, + networkRiskScore, + networkSpecificData, + pos, + tokenInfo, + ttl, + mutableMapOf(), + ) + + /** + * The provisional transaction group uuid associated with the authorization + * + * @throws LithicInvalidDataException if 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") + + /** + * Fee (in cents) assessed by the merchant and paid for by the cardholder. 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 or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun acquirerFee(): Long = acquirerFee.getRequired("acquirer_fee") + + /** + * Deprecated, use `amounts`. Authorization amount of the transaction (in cents), including any + * acquirer fees. The contents of this field are identical to `authorization_amount`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") fun amount(): Long = amount.getRequired("amount") + + /** + * Structured amounts for this authorization. The `cardholder` and `merchant` amounts reflect + * the original network authorization values. For programs with hold adjustments enabled (e.g., + * automated fuel dispensers or tipping MCCs), the `hold` amount may exceed the `cardholder` and + * `merchant` amounts to account for anticipated final transaction amounts such as tips or fuel + * fill-ups + * + * @throws LithicInvalidDataException if 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(): Amounts = amounts.getRequired("amounts") + + /** + * Deprecated, use `amounts`. The base transaction amount (in cents) plus the acquirer fee + * field. This is the amount the issuer should authorize against unless the issuer is paying the + * acquirer fee on behalf of the cardholder. + * + * @throws LithicInvalidDataException 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 authorizationAmount(): Long = authorizationAmount.getRequired("authorization_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun avs(): Avs = avs.getRequired("avs") + + /** + * Card object in ASA + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun card(): AsaRequestCard = card.getRequired("card") + + /** + * Deprecated, use `amounts`. 3-character alphabetic ISO 4217 code for cardholder's billing + * 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 cardholderCurrency(): String = cardholderCurrency.getRequired("cardholder_currency") + + /** + * The portion of the transaction requested as cash back by the cardholder, and does not include + * any acquirer fees. The amount field includes the purchase amount, the requested cash back + * amount, and any acquirer fees. + * + * If no cash back was requested, the value of this field will be 0, and the field will always + * be present. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cashAmount(): Long = cashAmount.getRequired("cash_amount") + + /** + * Date and time when the transaction first occurred in UTC. + * + * @throws LithicInvalidDataException if 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") + + /** + * Merchant information including full location details. + * + * @throws LithicInvalidDataException if 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(): TransactionMerchant = merchant.getRequired("merchant") + + /** + * Deprecated, use `amounts`. The amount that the merchant will receive, denominated in + * `merchant_currency` and in the smallest currency unit. Note the amount includes + * `acquirer_fee`, similar to `authorization_amount`. It will be different from + * `authorization_amount` if the merchant is taking payment in a different 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 merchantAmount(): Long = merchantAmount.getRequired("merchant_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") + + /** + * Where the cardholder received the service, when different from the card acceptor location. + * This is populated from network data elements such as Mastercard DE-122 SE1 SF9-14 and Visa + * F34 DS02. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceLocation(): Optional = + serviceLocation.getOptional("service_location") + + /** + * Deprecated, use `amounts`. Amount (in cents) of the transaction that has been settled, + * including any acquirer fees. + * + * @throws LithicInvalidDataException 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") + + /** + * The type of authorization request that this request is for. Note that `CREDIT_AUTHORIZATION` + * and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to users with credit decisioning via + * ASA enabled. + * + * @throws LithicInvalidDataException if 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(): AsaRequestStatus = status.getRequired("status") + + /** + * The entity that initiated 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 transactionInitiator(): TransactionInitiator = + transactionInitiator.getRequired("transaction_initiator") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountType(): Optional = accountType.getOptional("account_type") + + /** + * @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") + + /** + * Deprecated, use `cash_amount`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cashback(): Optional = cashback.getOptional("cashback") + + /** + * Deprecated, use `amounts`. If the transaction was requested in a currency other than the + * settlement currency, this field will be populated to indicate the rate used to translate the + * merchant_amount to the amount (i.e., `merchant_amount` x `conversion_rate` = `amount`). Note + * that the `merchant_amount` is in the local currency and the amount is in the 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 conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * The event token associated with the authorization. This field is only set for programs + * enrolled into the beta. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventToken(): Optional = eventToken.getOptional("event_token") + + /** + * Optional Object containing information if the Card is a part of a Fleet managed program + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fleetInfo(): Optional = fleetInfo.getOptional("fleet_info") + + /** + * The latest Authorization Challenge that was issued to the cardholder for this merchant. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun latestChallenge(): Optional = + latestChallenge.getOptional("latest_challenge") + + /** + * Card network of the authorization. + * + * @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") + + /** + * Contains raw data provided by the card network, including attributes that provide further + * context about the authorization. If populated by the network, data is organized by Lithic and + * passed through without further modification. Please consult the official network + * documentation for more details about these values and how to use them. This object is only + * available to certain programs- contact your Customer Success Manager to discuss enabling + * access. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkSpecificData(): Optional = + networkSpecificData.getOptional("network_specific_data") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pos(): Optional = pos.getOptional("pos") + + /** + * @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") + + /** + * Deprecated: approximate time-to-live for the authorization. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ttl(): Optional = ttl.getOptional("ttl") + + /** + * 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 [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 [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 [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 [card]. + * + * Unlike [card], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card") @ExcludeMissing fun _card(): JsonField = card + + /** + * Returns the raw JSON value of [cardholderCurrency]. + * + * Unlike [cardholderCurrency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("cardholder_currency") + @ExcludeMissing + fun _cardholderCurrency(): JsonField = cardholderCurrency + + /** + * Returns the raw JSON value of [cashAmount]. + * + * Unlike [cashAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cash_amount") @ExcludeMissing fun _cashAmount(): JsonField = cashAmount + + /** + * 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 [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 [serviceLocation]. + * + * Unlike [serviceLocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("service_location") + @ExcludeMissing + fun _serviceLocation(): JsonField = serviceLocation + + /** + * 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 [transactionInitiator]. + * + * Unlike [transactionInitiator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_initiator") + @ExcludeMissing + fun _transactionInitiator(): JsonField = transactionInitiator + + /** + * Returns the raw JSON value of [accountType]. + * + * Unlike [accountType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_type") + @ExcludeMissing + fun _accountType(): JsonField = accountType + + /** + * 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 [cashback]. + * + * Unlike [cashback], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cashback") @ExcludeMissing fun _cashback(): JsonField = cashback + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [eventToken]. + * + * Unlike [eventToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_token") @ExcludeMissing fun _eventToken(): JsonField = eventToken + + /** + * Returns the raw JSON value of [fleetInfo]. + * + * Unlike [fleetInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fleet_info") + @ExcludeMissing + fun _fleetInfo(): JsonField = fleetInfo + + /** + * Returns the raw JSON value of [latestChallenge]. + * + * Unlike [latestChallenge], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latest_challenge") + @ExcludeMissing + fun _latestChallenge(): JsonField = latestChallenge + + /** + * 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 [networkSpecificData]. + * + * Unlike [networkSpecificData], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_specific_data") + @ExcludeMissing + fun _networkSpecificData(): JsonField = networkSpecificData + + /** + * 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 [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 [ttl]. + * + * Unlike [ttl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ttl") @ExcludeMissing fun _ttl(): JsonField = ttl + + @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 [CardAuthorization]. + * + * The following fields are required: + * ```java + * .token() + * .acquirerFee() + * .amount() + * .amounts() + * .authorizationAmount() + * .avs() + * .card() + * .cardholderCurrency() + * .cashAmount() + * .created() + * .merchant() + * .merchantAmount() + * .merchantCurrency() + * .serviceLocation() + * .settledAmount() + * .status() + * .transactionInitiator() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardAuthorization]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var acquirerFee: JsonField? = null + private var amount: JsonField? = null + private var amounts: JsonField? = null + private var authorizationAmount: JsonField? = null + private var avs: JsonField? = null + private var card: JsonField? = null + private var cardholderCurrency: JsonField? = null + private var cashAmount: JsonField? = null + private var created: JsonField? = null + private var merchant: JsonField? = null + private var merchantAmount: JsonField? = null + private var merchantCurrency: JsonField? = null + private var serviceLocation: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var transactionInitiator: JsonField? = null + private var accountType: JsonField = JsonMissing.of() + private var cardholderAuthentication: JsonField = JsonMissing.of() + private var cashback: JsonField = JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var eventToken: JsonField = JsonMissing.of() + private var fleetInfo: JsonField = JsonMissing.of() + private var latestChallenge: JsonField = JsonMissing.of() + private var network: JsonField = JsonMissing.of() + private var networkRiskScore: JsonField = JsonMissing.of() + private var networkSpecificData: JsonField = JsonMissing.of() + private var pos: JsonField = JsonMissing.of() + private var tokenInfo: JsonField = JsonMissing.of() + private var ttl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardAuthorization: CardAuthorization) = apply { + token = cardAuthorization.token + acquirerFee = cardAuthorization.acquirerFee + amount = cardAuthorization.amount + amounts = cardAuthorization.amounts + authorizationAmount = cardAuthorization.authorizationAmount + avs = cardAuthorization.avs + card = cardAuthorization.card + cardholderCurrency = cardAuthorization.cardholderCurrency + cashAmount = cardAuthorization.cashAmount + created = cardAuthorization.created + merchant = cardAuthorization.merchant + merchantAmount = cardAuthorization.merchantAmount + merchantCurrency = cardAuthorization.merchantCurrency + serviceLocation = cardAuthorization.serviceLocation + settledAmount = cardAuthorization.settledAmount + status = cardAuthorization.status + transactionInitiator = cardAuthorization.transactionInitiator + accountType = cardAuthorization.accountType + cardholderAuthentication = cardAuthorization.cardholderAuthentication + cashback = cardAuthorization.cashback + conversionRate = cardAuthorization.conversionRate + eventToken = cardAuthorization.eventToken + fleetInfo = cardAuthorization.fleetInfo + latestChallenge = cardAuthorization.latestChallenge + network = cardAuthorization.network + networkRiskScore = cardAuthorization.networkRiskScore + networkSpecificData = cardAuthorization.networkSpecificData + pos = cardAuthorization.pos + tokenInfo = cardAuthorization.tokenInfo + ttl = cardAuthorization.ttl + additionalProperties = cardAuthorization.additionalProperties.toMutableMap() + } + + /** The provisional transaction group uuid associated with the authorization */ + 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 } + + /** + * Fee (in cents) assessed by the merchant and paid for by the cardholder. 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.of(acquirerFee)) + + /** + * 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 } + + /** + * Deprecated, use `amounts`. Authorization amount of the transaction (in cents), including + * any acquirer fees. The contents of this field are identical to `authorization_amount`. + */ + @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 } + + /** + * Structured amounts for this authorization. The `cardholder` and `merchant` amounts + * reflect the original network authorization values. For programs with hold adjustments + * enabled (e.g., automated fuel dispensers or tipping MCCs), the `hold` amount may exceed + * the `cardholder` and `merchant` amounts to account for anticipated final transaction + * amounts such as tips or fuel fill-ups + */ + fun amounts(amounts: Amounts) = amounts(JsonField.of(amounts)) + + /** + * Sets [Builder.amounts] to an arbitrary JSON value. + * + * You should usually call [Builder.amounts] with a well-typed [Amounts] 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 } + + /** + * Deprecated, use `amounts`. The base transaction amount (in cents) plus the acquirer fee + * field. This is the amount the issuer should authorize against unless the issuer is paying + * the acquirer fee on behalf of the cardholder. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long) = + authorizationAmount(JsonField.of(authorizationAmount)) + + /** + * 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 + } + + fun avs(avs: Avs) = avs(JsonField.of(avs)) + + /** + * Sets [Builder.avs] to an arbitrary JSON value. + * + * You should usually call [Builder.avs] with a well-typed [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 } + + /** Card object in ASA */ + fun card(card: AsaRequestCard) = card(JsonField.of(card)) + + /** + * Sets [Builder.card] to an arbitrary JSON value. + * + * You should usually call [Builder.card] with a well-typed [AsaRequestCard] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun card(card: JsonField) = apply { this.card = card } + + /** + * Deprecated, use `amounts`. 3-character alphabetic ISO 4217 code for cardholder's billing + * currency. + */ + @Deprecated("deprecated") + fun cardholderCurrency(cardholderCurrency: String) = + cardholderCurrency(JsonField.of(cardholderCurrency)) + + /** + * Sets [Builder.cardholderCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCurrency] 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 cardholderCurrency(cardholderCurrency: JsonField) = apply { + this.cardholderCurrency = cardholderCurrency + } + + /** + * The portion of the transaction requested as cash back by the cardholder, and does not + * include any acquirer fees. The amount field includes the purchase amount, the requested + * cash back amount, and any acquirer fees. + * + * If no cash back was requested, the value of this field will be 0, and the field will + * always be present. + */ + fun cashAmount(cashAmount: Long) = cashAmount(JsonField.of(cashAmount)) + + /** + * Sets [Builder.cashAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.cashAmount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cashAmount(cashAmount: JsonField) = apply { this.cashAmount = cashAmount } + + /** Date and time when the transaction first occurred in UTC. */ + 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 } + + /** Merchant information including full location details. */ + fun merchant(merchant: TransactionMerchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [TransactionMerchant] 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 } + + /** + * Deprecated, use `amounts`. The amount that the merchant will receive, denominated in + * `merchant_currency` and in the smallest currency unit. Note the amount includes + * `acquirer_fee`, similar to `authorization_amount`. It will be different from + * `authorization_amount` if the merchant is taking payment in a different currency. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long) = merchantAmount(JsonField.of(merchantAmount)) + + /** + * 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 + } + + /** 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 + } + + /** + * Where the cardholder received the service, when different from the card acceptor + * location. This is populated from network data elements such as Mastercard DE-122 SE1 + * SF9-14 and Visa F34 DS02. + */ + fun serviceLocation(serviceLocation: ServiceLocation?) = + serviceLocation(JsonField.ofNullable(serviceLocation)) + + /** Alias for calling [Builder.serviceLocation] with `serviceLocation.orElse(null)`. */ + fun serviceLocation(serviceLocation: Optional) = + serviceLocation(serviceLocation.getOrNull()) + + /** + * Sets [Builder.serviceLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceLocation] with a well-typed [ServiceLocation] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceLocation(serviceLocation: JsonField) = apply { + this.serviceLocation = serviceLocation + } + + /** + * Deprecated, use `amounts`. Amount (in cents) of the transaction that has been settled, + * including any acquirer fees. + */ + @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 + } + + /** + * The type of authorization request that this request is for. Note that + * `CREDIT_AUTHORIZATION` and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to users + * with credit decisioning via ASA enabled. + */ + fun status(status: AsaRequestStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [AsaRequestStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The entity that initiated the transaction. */ + fun transactionInitiator(transactionInitiator: TransactionInitiator) = + transactionInitiator(JsonField.of(transactionInitiator)) + + /** + * Sets [Builder.transactionInitiator] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionInitiator] with a well-typed + * [TransactionInitiator] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transactionInitiator(transactionInitiator: JsonField) = apply { + this.transactionInitiator = transactionInitiator + } + + fun accountType(accountType: AccountType) = accountType(JsonField.of(accountType)) + + /** + * Sets [Builder.accountType] to an arbitrary JSON value. + * + * You should usually call [Builder.accountType] with a well-typed [AccountType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountType(accountType: JsonField) = apply { + this.accountType = accountType + } + + fun cardholderAuthentication(cardholderAuthentication: CardholderAuthentication) = + cardholderAuthentication(JsonField.of(cardholderAuthentication)) + + /** + * Sets [Builder.cardholderAuthentication] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderAuthentication] with a well-typed + * [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 } + + /** Deprecated, use `cash_amount`. */ + fun cashback(cashback: Long) = cashback(JsonField.of(cashback)) + + /** + * Sets [Builder.cashback] to an arbitrary JSON value. + * + * You should usually call [Builder.cashback] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cashback(cashback: JsonField) = apply { this.cashback = cashback } + + /** + * Deprecated, use `amounts`. If the transaction was requested in a currency other than the + * settlement currency, this field will be populated to indicate the rate used to translate + * the merchant_amount to the amount (i.e., `merchant_amount` x `conversion_rate` = + * `amount`). Note that the `merchant_amount` is in the local currency and the amount is in + * the settlement currency. + */ + @Deprecated("deprecated") + fun conversionRate(conversionRate: Double) = conversionRate(JsonField.of(conversionRate)) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The event token associated with the authorization. This field is only set for programs + * enrolled into the beta. + */ + fun eventToken(eventToken: String) = eventToken(JsonField.of(eventToken)) + + /** + * Sets [Builder.eventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.eventToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun eventToken(eventToken: JsonField) = apply { this.eventToken = eventToken } + + /** + * Optional Object containing information if the Card is a part of a Fleet managed program + */ + fun fleetInfo(fleetInfo: AsaRequestFleetInfo?) = fleetInfo(JsonField.ofNullable(fleetInfo)) + + /** Alias for calling [Builder.fleetInfo] with `fleetInfo.orElse(null)`. */ + fun fleetInfo(fleetInfo: Optional) = fleetInfo(fleetInfo.getOrNull()) + + /** + * Sets [Builder.fleetInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.fleetInfo] with a well-typed [AsaRequestFleetInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fleetInfo(fleetInfo: JsonField) = apply { + this.fleetInfo = fleetInfo + } + + /** + * The latest Authorization Challenge that was issued to the cardholder for this merchant. + */ + fun latestChallenge(latestChallenge: LatestChallenge) = + latestChallenge(JsonField.of(latestChallenge)) + + /** + * Sets [Builder.latestChallenge] to an arbitrary JSON value. + * + * You should usually call [Builder.latestChallenge] with a well-typed [LatestChallenge] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun latestChallenge(latestChallenge: JsonField) = apply { + this.latestChallenge = latestChallenge + } + + /** Card network of the authorization. */ + fun network(network: Network) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [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 + } + + /** + * Contains raw data provided by the card network, including attributes that provide further + * context about the authorization. If populated by the network, data is organized by Lithic + * and passed through without further modification. Please consult the official network + * documentation for more details about these values and how to use them. This object is + * only available to certain programs- contact your Customer Success Manager to discuss + * enabling access. + */ + fun networkSpecificData(networkSpecificData: AsaNetworkSpecificData?) = + networkSpecificData(JsonField.ofNullable(networkSpecificData)) + + /** + * Alias for calling [Builder.networkSpecificData] with `networkSpecificData.orElse(null)`. + */ + fun networkSpecificData(networkSpecificData: Optional) = + networkSpecificData(networkSpecificData.getOrNull()) + + /** + * Sets [Builder.networkSpecificData] to an arbitrary JSON value. + * + * You should usually call [Builder.networkSpecificData] with a well-typed + * [AsaNetworkSpecificData] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun networkSpecificData(networkSpecificData: JsonField) = apply { + this.networkSpecificData = networkSpecificData + } + + fun pos(pos: Pos) = pos(JsonField.of(pos)) + + /** + * Sets [Builder.pos] to an arbitrary JSON value. + * + * You should usually call [Builder.pos] with a well-typed [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 tokenInfo(tokenInfo: 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 [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 } + + /** Deprecated: approximate time-to-live for the authorization. */ + fun ttl(ttl: OffsetDateTime) = ttl(JsonField.of(ttl)) + + /** + * Sets [Builder.ttl] to an arbitrary JSON value. + * + * You should usually call [Builder.ttl] with a well-typed [OffsetDateTime] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ttl(ttl: JsonField) = apply { this.ttl = ttl } + + 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 [CardAuthorization]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .acquirerFee() + * .amount() + * .amounts() + * .authorizationAmount() + * .avs() + * .card() + * .cardholderCurrency() + * .cashAmount() + * .created() + * .merchant() + * .merchantAmount() + * .merchantCurrency() + * .serviceLocation() + * .settledAmount() + * .status() + * .transactionInitiator() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardAuthorization = + CardAuthorization( + checkRequired("token", token), + checkRequired("acquirerFee", acquirerFee), + checkRequired("amount", amount), + checkRequired("amounts", amounts), + checkRequired("authorizationAmount", authorizationAmount), + checkRequired("avs", avs), + checkRequired("card", card), + checkRequired("cardholderCurrency", cardholderCurrency), + checkRequired("cashAmount", cashAmount), + checkRequired("created", created), + checkRequired("merchant", merchant), + checkRequired("merchantAmount", merchantAmount), + checkRequired("merchantCurrency", merchantCurrency), + checkRequired("serviceLocation", serviceLocation), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("transactionInitiator", transactionInitiator), + accountType, + cardholderAuthentication, + cashback, + conversionRate, + eventToken, + fleetInfo, + latestChallenge, + network, + networkRiskScore, + networkSpecificData, + pos, + tokenInfo, + ttl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CardAuthorization = apply { + if (validated) { + return@apply + } + + token() + acquirerFee() + amount() + amounts().validate() + authorizationAmount() + avs().validate() + card().validate() + cardholderCurrency() + cashAmount() + created() + merchant().validate() + merchantAmount() + merchantCurrency() + serviceLocation().ifPresent { it.validate() } + settledAmount() + status().validate() + transactionInitiator().validate() + accountType().ifPresent { it.validate() } + cardholderAuthentication().ifPresent { it.validate() } + cashback() + conversionRate() + eventToken() + fleetInfo().ifPresent { it.validate() } + latestChallenge().ifPresent { it.validate() } + network().ifPresent { it.validate() } + networkRiskScore() + networkSpecificData().ifPresent { it.validate() } + pos().ifPresent { it.validate() } + tokenInfo().ifPresent { it.validate() } + ttl() + 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 (acquirerFee.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (amounts.asKnown().getOrNull()?.validity() ?: 0) + + (if (authorizationAmount.asKnown().isPresent) 1 else 0) + + (avs.asKnown().getOrNull()?.validity() ?: 0) + + (card.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + + (if (cashAmount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (merchantAmount.asKnown().isPresent) 1 else 0) + + (if (merchantCurrency.asKnown().isPresent) 1 else 0) + + (serviceLocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (transactionInitiator.asKnown().getOrNull()?.validity() ?: 0) + + (accountType.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderAuthentication.asKnown().getOrNull()?.validity() ?: 0) + + (if (cashback.asKnown().isPresent) 1 else 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (eventToken.asKnown().isPresent) 1 else 0) + + (fleetInfo.asKnown().getOrNull()?.validity() ?: 0) + + (latestChallenge.asKnown().getOrNull()?.validity() ?: 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (networkRiskScore.asKnown().isPresent) 1 else 0) + + (networkSpecificData.asKnown().getOrNull()?.validity() ?: 0) + + (pos.asKnown().getOrNull()?.validity() ?: 0) + + (tokenInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (ttl.asKnown().isPresent) 1 else 0) + + /** + * Structured amounts for this authorization. The `cardholder` and `merchant` amounts reflect + * the original network authorization values. For programs with hold adjustments enabled (e.g., + * automated fuel dispensers or tipping MCCs), the `hold` amount may exceed the `cardholder` and + * `merchant` amounts to account for anticipated final transaction amounts such as tips or fuel + * fill-ups + */ + class Amounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholder: JsonField, + private val hold: JsonField, + private val merchant: JsonField, + private val settlement: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder") + @ExcludeMissing + cardholder: JsonField = JsonMissing.of(), + @JsonProperty("hold") @ExcludeMissing hold: JsonField = JsonMissing.of(), + @JsonProperty("merchant") + @ExcludeMissing + merchant: JsonField = JsonMissing.of(), + @JsonProperty("settlement") + @ExcludeMissing + settlement: JsonField = JsonMissing.of(), + ) : this(cardholder, hold, merchant, settlement, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardholder(): ConvertedAmount = cardholder.getRequired("cardholder") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hold(): Optional = hold.getOptional("hold") + + /** + * @throws LithicInvalidDataException if 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(): Amount = merchant.getRequired("merchant") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settlement(): Optional = settlement.getOptional("settlement") + + /** + * Returns the raw JSON value of [cardholder]. + * + * Unlike [cardholder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cardholder") + @ExcludeMissing + fun _cardholder(): JsonField = cardholder + + /** + * Returns the raw JSON value of [hold]. + * + * Unlike [hold], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hold") @ExcludeMissing fun _hold(): JsonField = hold + + /** + * 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 [settlement]. + * + * Unlike [settlement], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settlement") + @ExcludeMissing + fun _settlement(): JsonField = settlement + + @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 [Amounts]. + * + * The following fields are required: + * ```java + * .cardholder() + * .hold() + * .merchant() + * .settlement() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Amounts]. */ + class Builder internal constructor() { + + private var cardholder: JsonField? = null + private var hold: JsonField? = null + private var merchant: JsonField? = null + private var settlement: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amounts: Amounts) = apply { + cardholder = amounts.cardholder + hold = amounts.hold + merchant = amounts.merchant + settlement = amounts.settlement + additionalProperties = amounts.additionalProperties.toMutableMap() + } + + fun cardholder(cardholder: ConvertedAmount) = cardholder(JsonField.of(cardholder)) + + /** + * Sets [Builder.cardholder] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholder] with a well-typed [ConvertedAmount] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cardholder(cardholder: JsonField) = apply { + this.cardholder = cardholder + } + + fun hold(hold: Amount?) = hold(JsonField.ofNullable(hold)) + + /** Alias for calling [Builder.hold] with `hold.orElse(null)`. */ + fun hold(hold: Optional) = hold(hold.getOrNull()) + + /** + * Sets [Builder.hold] to an arbitrary JSON value. + * + * You should usually call [Builder.hold] with a well-typed [Amount] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hold(hold: JsonField) = apply { this.hold = hold } + + fun merchant(merchant: Amount) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Amount] 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 } + + fun settlement(settlement: Amount?) = settlement(JsonField.ofNullable(settlement)) + + /** Alias for calling [Builder.settlement] with `settlement.orElse(null)`. */ + fun settlement(settlement: Optional) = settlement(settlement.getOrNull()) + + /** + * Sets [Builder.settlement] to an arbitrary JSON value. + * + * You should usually call [Builder.settlement] with a well-typed [Amount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settlement(settlement: JsonField) = apply { this.settlement = settlement } + + 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 [Amounts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholder() + * .hold() + * .merchant() + * .settlement() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Amounts = + Amounts( + checkRequired("cardholder", cardholder), + checkRequired("hold", hold), + checkRequired("merchant", merchant), + checkRequired("settlement", settlement), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Amounts = apply { + if (validated) { + return@apply + } + + cardholder().validate() + hold().ifPresent { it.validate() } + merchant().validate() + settlement().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholder.asKnown().getOrNull()?.validity() ?: 0) + + (hold.asKnown().getOrNull()?.validity() ?: 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (settlement.asKnown().getOrNull()?.validity() ?: 0) + + class ConvertedAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val conversionRate: JsonField, + private val currency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + ) : this(amount, conversionRate, currency, mutableMapOf()) + + /** + * Amount in the smallest unit of the applicable currency (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") + + /** + * Exchange rate used for currency conversion + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun conversionRate(): String = conversionRate.getRequired("conversion_rate") + + /** + * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * 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 + + @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 [ConvertedAmount]. + * + * The following fields are required: + * ```java + * .amount() + * .conversionRate() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConvertedAmount]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var conversionRate: JsonField? = null + private var currency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(convertedAmount: ConvertedAmount) = apply { + amount = convertedAmount.amount + conversionRate = convertedAmount.conversionRate + currency = convertedAmount.currency + additionalProperties = convertedAmount.additionalProperties.toMutableMap() + } + + /** Amount in the smallest unit of the applicable currency (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 } + + /** Exchange rate used for currency conversion */ + fun conversionRate(conversionRate: String) = + conversionRate(JsonField.of(conversionRate)) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** 3-character alphabetic ISO 4217 currency */ + 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 } + + 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 [ConvertedAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .conversionRate() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConvertedAmount = + ConvertedAmount( + checkRequired("amount", amount), + checkRequired("conversionRate", conversionRate), + checkRequired("currency", currency), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ConvertedAmount = apply { + if (validated) { + return@apply + } + + amount() + conversionRate() + currency() + 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 (amount.asKnown().isPresent) 1 else 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConvertedAmount && + amount == other.amount && + conversionRate == other.conversionRate && + currency == other.currency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, conversionRate, currency, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConvertedAmount{amount=$amount, conversionRate=$conversionRate, currency=$currency, additionalProperties=$additionalProperties}" + } + + class Amount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + ) : this(amount, currency, mutableMapOf()) + + /** + * Amount in the smallest unit of the applicable currency (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") + + /** + * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @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 [Amount]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Amount]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amount: Amount) = apply { + this.amount = amount.amount + currency = amount.currency + additionalProperties = amount.additionalProperties.toMutableMap() + } + + /** Amount in the smallest unit of the applicable currency (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 } + + /** 3-character alphabetic ISO 4217 currency */ + 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 } + + 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 [Amount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Amount = + Amount( + checkRequired("amount", amount), + checkRequired("currency", currency), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Amount = apply { + if (validated) { + return@apply + } + + amount() + currency() + 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 (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Amount && + amount == other.amount && + currency == other.currency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Amount{amount=$amount, currency=$currency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Amounts && + cardholder == other.cardholder && + hold == other.hold && + merchant == other.merchant && + settlement == other.settlement && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cardholder, hold, merchant, settlement, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Amounts{cardholder=$cardholder, hold=$hold, merchant=$merchant, settlement=$settlement, additionalProperties=$additionalProperties}" + } + + class Avs + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField, + private val addressOnFileMatch: JsonField, + private val zipcode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") @ExcludeMissing address: JsonField = JsonMissing.of(), + @JsonProperty("address_on_file_match") + @ExcludeMissing + addressOnFileMatch: JsonField = JsonMissing.of(), + @JsonProperty("zipcode") @ExcludeMissing zipcode: JsonField = JsonMissing.of(), + ) : this(address, addressOnFileMatch, zipcode, mutableMapOf()) + + /** + * Cardholder address + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun address(): String = address.getRequired("address") + + /** + * Lithic's evaluation result comparing the transaction's address data with the cardholder + * KYC data if it exists. In the event Lithic does not have any Cardholder KYC data, or the + * transaction does not contain any address data, NOT_PRESENT will be returned + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun addressOnFileMatch(): AddressMatchResult = + addressOnFileMatch.getRequired("address_on_file_match") + + /** + * Cardholder ZIP code + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun zipcode(): String = zipcode.getRequired("zipcode") + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address + + /** + * Returns the raw JSON value of [addressOnFileMatch]. + * + * Unlike [addressOnFileMatch], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address_on_file_match") + @ExcludeMissing + fun _addressOnFileMatch(): JsonField = addressOnFileMatch + + /** + * Returns the raw JSON value of [zipcode]. + * + * Unlike [zipcode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("zipcode") @ExcludeMissing fun _zipcode(): JsonField = zipcode + + @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 [Avs]. + * + * The following fields are required: + * ```java + * .address() + * .addressOnFileMatch() + * .zipcode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Avs]. */ + class Builder internal constructor() { + + private var address: JsonField? = null + private var addressOnFileMatch: JsonField? = null + private var zipcode: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(avs: Avs) = apply { + address = avs.address + addressOnFileMatch = avs.addressOnFileMatch + zipcode = avs.zipcode + additionalProperties = avs.additionalProperties.toMutableMap() + } + + /** Cardholder address */ + fun address(address: String) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun address(address: JsonField) = apply { this.address = address } + + /** + * Lithic's evaluation result comparing the transaction's address data with the + * cardholder KYC data if it exists. In the event Lithic does not have any Cardholder + * KYC data, or the transaction does not contain any address data, NOT_PRESENT will be + * returned + */ + fun addressOnFileMatch(addressOnFileMatch: AddressMatchResult) = + addressOnFileMatch(JsonField.of(addressOnFileMatch)) + + /** + * Sets [Builder.addressOnFileMatch] to an arbitrary JSON value. + * + * You should usually call [Builder.addressOnFileMatch] with a well-typed + * [AddressMatchResult] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun addressOnFileMatch(addressOnFileMatch: JsonField) = apply { + this.addressOnFileMatch = addressOnFileMatch + } + + /** Cardholder ZIP code */ + fun zipcode(zipcode: String) = zipcode(JsonField.of(zipcode)) + + /** + * Sets [Builder.zipcode] to an arbitrary JSON value. + * + * You should usually call [Builder.zipcode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun zipcode(zipcode: JsonField) = apply { this.zipcode = zipcode } + + 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 [Avs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address() + * .addressOnFileMatch() + * .zipcode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Avs = + Avs( + checkRequired("address", address), + checkRequired("addressOnFileMatch", addressOnFileMatch), + checkRequired("zipcode", zipcode), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Avs = apply { + if (validated) { + return@apply + } + + address() + addressOnFileMatch().validate() + zipcode() + 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 (address.asKnown().isPresent) 1 else 0) + + (addressOnFileMatch.asKnown().getOrNull()?.validity() ?: 0) + + (if (zipcode.asKnown().isPresent) 1 else 0) + + /** + * Lithic's evaluation result comparing the transaction's address data with the cardholder + * KYC data if it exists. In the event Lithic does not have any Cardholder KYC data, or the + * transaction does not contain any address data, NOT_PRESENT will be returned + */ + class AddressMatchResult + @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 MATCH = of("MATCH") + + @JvmField val MATCH_ADDRESS_ONLY = of("MATCH_ADDRESS_ONLY") + + @JvmField val MATCH_ZIP_ONLY = of("MATCH_ZIP_ONLY") + + @JvmField val MISMATCH = of("MISMATCH") + + @JvmField val NOT_PRESENT = of("NOT_PRESENT") + + @JvmStatic fun of(value: String) = AddressMatchResult(JsonField.of(value)) + } + + /** An enum containing [AddressMatchResult]'s known values. */ + enum class Known { + MATCH, + MATCH_ADDRESS_ONLY, + MATCH_ZIP_ONLY, + MISMATCH, + NOT_PRESENT, + } + + /** + * An enum containing [AddressMatchResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AddressMatchResult] 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 { + MATCH, + MATCH_ADDRESS_ONLY, + MATCH_ZIP_ONLY, + MISMATCH, + NOT_PRESENT, + /** + * An enum member indicating that [AddressMatchResult] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATCH -> Value.MATCH + MATCH_ADDRESS_ONLY -> Value.MATCH_ADDRESS_ONLY + MATCH_ZIP_ONLY -> Value.MATCH_ZIP_ONLY + MISMATCH -> Value.MISMATCH + NOT_PRESENT -> Value.NOT_PRESENT + 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) { + MATCH -> Known.MATCH + MATCH_ADDRESS_ONLY -> Known.MATCH_ADDRESS_ONLY + MATCH_ZIP_ONLY -> Known.MATCH_ZIP_ONLY + MISMATCH -> Known.MISMATCH + NOT_PRESENT -> Known.NOT_PRESENT + else -> throw LithicInvalidDataException("Unknown AddressMatchResult: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AddressMatchResult = 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 AddressMatchResult && 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 Avs && + address == other.address && + addressOnFileMatch == other.addressOnFileMatch && + zipcode == other.zipcode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(address, addressOnFileMatch, zipcode, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Avs{address=$address, addressOnFileMatch=$addressOnFileMatch, zipcode=$zipcode, additionalProperties=$additionalProperties}" + } + + /** Card object in ASA */ + class AsaRequestCard + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val lastFour: JsonField, + private val memo: JsonField, + private val spendLimit: JsonField, + private val spendLimitDuration: JsonField, + private val state: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("last_four") + @ExcludeMissing + lastFour: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("spend_limit") + @ExcludeMissing + spendLimit: JsonField = JsonMissing.of(), + @JsonProperty("spend_limit_duration") + @ExcludeMissing + spendLimitDuration: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(token, lastFour, memo, spendLimit, spendLimitDuration, state, type, mutableMapOf()) + + /** + * Globally unique identifier for the card. + * + * @throws LithicInvalidDataException if 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") + + /** + * Last four digits of the card number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lastFour(): String = lastFour.getRequired("last_four") + + /** + * Customizable name to identify the card + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun memo(): String = memo.getRequired("memo") + + /** + * Amount (in cents) to limit approved authorizations. Purchase requests above the spend + * limit will be declined (refunds and credits will be approved). + * + * Note that while spend limits are enforced based on authorized and settled volume on a + * card, they are not recommended to be used for balance or reconciliation-level accuracy. + * Spend limits also cannot block force posted charges (i.e., when a merchant sends a + * clearing message without a prior authorization). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun spendLimit(): Long = spendLimit.getRequired("spend_limit") + + /** + * Note that to support recurring monthly payments, which can occur on different day every + * month, the time window we consider for MONTHLY velocity starts 6 days after the current + * calendar date one month prior. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun spendLimitDuration(): SpendLimitDuration = + spendLimitDuration.getRequired("spend_limit_duration") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun state(): State = state.getRequired("state") + + /** + * @throws LithicInvalidDataException if 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(): CardType = type.getRequired("type") + + /** + * 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 [lastFour]. + * + * Unlike [lastFour], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [spendLimit]. + * + * Unlike [spendLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit(): JsonField = spendLimit + + /** + * Returns the raw JSON value of [spendLimitDuration]. + * + * Unlike [spendLimitDuration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("spend_limit_duration") + @ExcludeMissing + fun _spendLimitDuration(): JsonField = spendLimitDuration + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AsaRequestCard]. + * + * The following fields are required: + * ```java + * .token() + * .lastFour() + * .memo() + * .spendLimit() + * .spendLimitDuration() + * .state() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaRequestCard]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var lastFour: JsonField? = null + private var memo: JsonField? = null + private var spendLimit: JsonField? = null + private var spendLimitDuration: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaRequestCard: AsaRequestCard) = apply { + token = asaRequestCard.token + lastFour = asaRequestCard.lastFour + memo = asaRequestCard.memo + spendLimit = asaRequestCard.spendLimit + spendLimitDuration = asaRequestCard.spendLimitDuration + state = asaRequestCard.state + type = asaRequestCard.type + additionalProperties = asaRequestCard.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the card. */ + 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 } + + /** Last four digits of the card number */ + fun lastFour(lastFour: String) = lastFour(JsonField.of(lastFour)) + + /** + * Sets [Builder.lastFour] to an arbitrary JSON value. + * + * You should usually call [Builder.lastFour] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastFour(lastFour: JsonField) = apply { this.lastFour = lastFour } + + /** Customizable name to identify the card */ + fun memo(memo: String) = memo(JsonField.of(memo)) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * 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 memo(memo: JsonField) = apply { this.memo = memo } + + /** + * Amount (in cents) to limit approved authorizations. Purchase requests above the spend + * limit will be declined (refunds and credits will be approved). + * + * Note that while spend limits are enforced based on authorized and settled volume on a + * card, they are not recommended to be used for balance or reconciliation-level + * accuracy. Spend limits also cannot block force posted charges (i.e., when a merchant + * sends a clearing message without a prior authorization). + */ + fun spendLimit(spendLimit: Long) = spendLimit(JsonField.of(spendLimit)) + + /** + * Sets [Builder.spendLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.spendLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun spendLimit(spendLimit: JsonField) = apply { this.spendLimit = spendLimit } + + /** + * Note that to support recurring monthly payments, which can occur on different day + * every month, the time window we consider for MONTHLY velocity starts 6 days after the + * current calendar date one month prior. + */ + fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = + spendLimitDuration(JsonField.of(spendLimitDuration)) + + /** + * Sets [Builder.spendLimitDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.spendLimitDuration] with a well-typed + * [SpendLimitDuration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun spendLimitDuration(spendLimitDuration: JsonField) = apply { + this.spendLimitDuration = spendLimitDuration + } + + fun state(state: State) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [State] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun state(state: JsonField) = apply { this.state = state } + + fun type(type: CardType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [CardType] 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 [AsaRequestCard]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .lastFour() + * .memo() + * .spendLimit() + * .spendLimitDuration() + * .state() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AsaRequestCard = + AsaRequestCard( + checkRequired("token", token), + checkRequired("lastFour", lastFour), + checkRequired("memo", memo), + checkRequired("spendLimit", spendLimit), + checkRequired("spendLimitDuration", spendLimitDuration), + checkRequired("state", state), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaRequestCard = apply { + if (validated) { + return@apply + } + + token() + lastFour() + memo() + spendLimit() + spendLimitDuration().validate() + state().validate() + type().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 (lastFour.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (spendLimit.asKnown().isPresent) 1 else 0) + + (spendLimitDuration.asKnown().getOrNull()?.validity() ?: 0) + + (state.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Note that to support recurring monthly payments, which can occur on different day every + * month, the time window we consider for MONTHLY velocity starts 6 days after the current + * calendar date one month prior. + */ + class SpendLimitDuration + @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 ANNUALLY = of("ANNUALLY") + + @JvmField val FOREVER = of("FOREVER") + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val TRANSACTION = of("TRANSACTION") + + @JvmStatic fun of(value: String) = SpendLimitDuration(JsonField.of(value)) + } + + /** An enum containing [SpendLimitDuration]'s known values. */ + enum class Known { + ANNUALLY, + FOREVER, + MONTHLY, + TRANSACTION, + } + + /** + * An enum containing [SpendLimitDuration]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [SpendLimitDuration] 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 { + ANNUALLY, + FOREVER, + MONTHLY, + TRANSACTION, + /** + * An enum member indicating that [SpendLimitDuration] 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) { + ANNUALLY -> Value.ANNUALLY + FOREVER -> Value.FOREVER + MONTHLY -> Value.MONTHLY + TRANSACTION -> Value.TRANSACTION + 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) { + ANNUALLY -> Known.ANNUALLY + FOREVER -> Known.FOREVER + MONTHLY -> Known.MONTHLY + TRANSACTION -> Known.TRANSACTION + else -> throw LithicInvalidDataException("Unknown SpendLimitDuration: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SpendLimitDuration = 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 SpendLimitDuration && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class State @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 CLOSED = of("CLOSED") + + @JvmField val OPEN = of("OPEN") + + @JvmField val PAUSED = of("PAUSED") + + @JvmField val PENDING_ACTIVATION = of("PENDING_ACTIVATION") + + @JvmField val PENDING_FULFILLMENT = of("PENDING_FULFILLMENT") + + @JvmStatic fun of(value: String) = State(JsonField.of(value)) + } + + /** An enum containing [State]'s known values. */ + enum class Known { + CLOSED, + OPEN, + PAUSED, + PENDING_ACTIVATION, + PENDING_FULFILLMENT, + } + + /** + * An enum containing [State]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [State] 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 { + CLOSED, + OPEN, + PAUSED, + PENDING_ACTIVATION, + PENDING_FULFILLMENT, + /** + * An enum member indicating that [State] 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) { + CLOSED -> Value.CLOSED + OPEN -> Value.OPEN + PAUSED -> Value.PAUSED + PENDING_ACTIVATION -> Value.PENDING_ACTIVATION + PENDING_FULFILLMENT -> Value.PENDING_FULFILLMENT + 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) { + CLOSED -> Known.CLOSED + OPEN -> Known.OPEN + PAUSED -> Known.PAUSED + PENDING_ACTIVATION -> Known.PENDING_ACTIVATION + PENDING_FULFILLMENT -> Known.PENDING_FULFILLMENT + else -> throw LithicInvalidDataException("Unknown State: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): State = 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 State && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CardType @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 SINGLE_USE = of("SINGLE_USE") + + @JvmField val MERCHANT_LOCKED = of("MERCHANT_LOCKED") + + @JvmField val UNLOCKED = of("UNLOCKED") + + @JvmField val PHYSICAL = of("PHYSICAL") + + @JvmField val DIGITAL_WALLET = of("DIGITAL_WALLET") + + @JvmField val VIRTUAL = of("VIRTUAL") + + @JvmStatic fun of(value: String) = CardType(JsonField.of(value)) + } + + /** An enum containing [CardType]'s known values. */ + enum class Known { + SINGLE_USE, + MERCHANT_LOCKED, + UNLOCKED, + PHYSICAL, + DIGITAL_WALLET, + VIRTUAL, + } + + /** + * An enum containing [CardType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CardType] 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 { + SINGLE_USE, + MERCHANT_LOCKED, + UNLOCKED, + PHYSICAL, + DIGITAL_WALLET, + VIRTUAL, + /** + * An enum member indicating that [CardType] 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) { + SINGLE_USE -> Value.SINGLE_USE + MERCHANT_LOCKED -> Value.MERCHANT_LOCKED + UNLOCKED -> Value.UNLOCKED + PHYSICAL -> Value.PHYSICAL + DIGITAL_WALLET -> Value.DIGITAL_WALLET + VIRTUAL -> Value.VIRTUAL + 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) { + SINGLE_USE -> Known.SINGLE_USE + MERCHANT_LOCKED -> Known.MERCHANT_LOCKED + UNLOCKED -> Known.UNLOCKED + PHYSICAL -> Known.PHYSICAL + DIGITAL_WALLET -> Known.DIGITAL_WALLET + VIRTUAL -> Known.VIRTUAL + else -> throw LithicInvalidDataException("Unknown CardType: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CardType = 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 CardType && 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 AsaRequestCard && + token == other.token && + lastFour == other.lastFour && + memo == other.memo && + spendLimit == other.spendLimit && + spendLimitDuration == other.spendLimitDuration && + state == other.state && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + lastFour, + memo, + spendLimit, + spendLimitDuration, + state, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaRequestCard{token=$token, lastFour=$lastFour, memo=$memo, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, additionalProperties=$additionalProperties}" + } + + /** Merchant information including full location details. */ + class TransactionMerchant + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptorId: JsonField, + private val acquiringInstitutionId: JsonField, + private val city: JsonField, + private val country: JsonField, + private val descriptor: JsonField, + private val mcc: JsonField, + private val state: JsonField, + private val phoneNumber: JsonField, + private val postalCode: JsonField, + private val streetAddress: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("acceptor_id") + @ExcludeMissing + acceptorId: JsonField = JsonMissing.of(), + @JsonProperty("acquiring_institution_id") + @ExcludeMissing + acquiringInstitutionId: JsonField = JsonMissing.of(), + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("mcc") @ExcludeMissing mcc: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("street_address") + @ExcludeMissing + streetAddress: JsonField = JsonMissing.of(), + ) : this( + acceptorId, + acquiringInstitutionId, + city, + country, + descriptor, + mcc, + state, + phoneNumber, + postalCode, + streetAddress, + mutableMapOf(), + ) + + fun toMerchant(): Merchant = + Merchant.builder() + .acceptorId(acceptorId) + .acquiringInstitutionId(acquiringInstitutionId) + .city(city) + .country(country) + .descriptor(descriptor) + .mcc(mcc) + .state(state) + .build() + + /** + * Unique alphanumeric identifier for the payment card acceptor (merchant). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun acceptorId(): String = acceptorId.getRequired("acceptor_id") + + /** + * Unique numeric identifier of the acquiring institution. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun acquiringInstitutionId(): String = + acquiringInstitutionId.getRequired("acquiring_institution_id") + + /** + * City of card acceptor. Note that in many cases, particularly in card-not-present + * transactions, merchants may send through a phone number or URL in this field. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun city(): String = city.getRequired("city") + + /** + * Country or entity of card acceptor. Possible values are: (1) all ISO 3166-1 alpha-3 + * country codes, (2) QZZ for Kosovo, and (3) ANT for Netherlands Antilles. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Short description of card acceptor. + * + * @throws LithicInvalidDataException if 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") + + /** + * Merchant category code (MCC). A four-digit number listed in ISO 18245. An MCC is used to + * classify a business by the types of goods or services it provides. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun mcc(): String = mcc.getRequired("mcc") + + /** + * Geographic state of card acceptor. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun state(): String = state.getRequired("state") + + /** + * Phone number of card acceptor. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") + + /** + * Postal code of card acceptor. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * Street address of card acceptor. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streetAddress(): Optional = streetAddress.getOptional("street_address") + + /** + * Returns the raw JSON value of [acceptorId]. + * + * Unlike [acceptorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("acceptor_id") + @ExcludeMissing + fun _acceptorId(): JsonField = acceptorId + + /** + * Returns the raw JSON value of [acquiringInstitutionId]. + * + * Unlike [acquiringInstitutionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("acquiring_institution_id") + @ExcludeMissing + fun _acquiringInstitutionId(): JsonField = acquiringInstitutionId + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [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 [mcc]. + * + * Unlike [mcc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [streetAddress]. + * + * Unlike [streetAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("street_address") + @ExcludeMissing + fun _streetAddress(): JsonField = streetAddress + + @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 [TransactionMerchant]. + * + * The following fields are required: + * ```java + * .acceptorId() + * .acquiringInstitutionId() + * .city() + * .country() + * .descriptor() + * .mcc() + * .state() + * .phoneNumber() + * .postalCode() + * .streetAddress() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TransactionMerchant]. */ + class Builder internal constructor() { + + private var acceptorId: JsonField? = null + private var acquiringInstitutionId: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var descriptor: JsonField? = null + private var mcc: JsonField? = null + private var state: JsonField? = null + private var phoneNumber: JsonField? = null + private var postalCode: JsonField? = null + private var streetAddress: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transactionMerchant: TransactionMerchant) = apply { + acceptorId = transactionMerchant.acceptorId + acquiringInstitutionId = transactionMerchant.acquiringInstitutionId + city = transactionMerchant.city + country = transactionMerchant.country + descriptor = transactionMerchant.descriptor + mcc = transactionMerchant.mcc + state = transactionMerchant.state + phoneNumber = transactionMerchant.phoneNumber + postalCode = transactionMerchant.postalCode + streetAddress = transactionMerchant.streetAddress + additionalProperties = transactionMerchant.additionalProperties.toMutableMap() + } + + /** Unique alphanumeric identifier for the payment card acceptor (merchant). */ + fun acceptorId(acceptorId: String) = acceptorId(JsonField.of(acceptorId)) + + /** + * Sets [Builder.acceptorId] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptorId(acceptorId: JsonField) = apply { this.acceptorId = acceptorId } + + /** Unique numeric identifier of the acquiring institution. */ + fun acquiringInstitutionId(acquiringInstitutionId: String) = + acquiringInstitutionId(JsonField.of(acquiringInstitutionId)) + + /** + * Sets [Builder.acquiringInstitutionId] to an arbitrary JSON value. + * + * You should usually call [Builder.acquiringInstitutionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun acquiringInstitutionId(acquiringInstitutionId: JsonField) = apply { + this.acquiringInstitutionId = acquiringInstitutionId + } + + /** + * City of card acceptor. Note that in many cases, particularly in card-not-present + * transactions, merchants may send through a phone number or URL in this field. + */ + fun city(city: String) = city(JsonField.of(city)) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** + * Country or entity of card acceptor. Possible values are: (1) all ISO 3166-1 alpha-3 + * country codes, (2) QZZ for Kosovo, and (3) ANT for Netherlands Antilles. + */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** Short description of card acceptor. */ + 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 } + + /** + * Merchant category code (MCC). A four-digit number listed in ISO 18245. An MCC is used + * to classify a business by the types of goods or services it provides. + */ + fun mcc(mcc: String) = mcc(JsonField.of(mcc)) + + /** + * Sets [Builder.mcc] to an arbitrary JSON value. + * + * You should usually call [Builder.mcc] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mcc(mcc: JsonField) = apply { this.mcc = mcc } + + /** Geographic state of card acceptor. */ + fun state(state: String) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + /** Phone number of card acceptor. */ + fun phoneNumber(phoneNumber: String?) = phoneNumber(JsonField.ofNullable(phoneNumber)) + + /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ + fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.getOrNull()) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } + + /** Postal code of card acceptor. */ + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + /** Alias for calling [Builder.postalCode] with `postalCode.orElse(null)`. */ + fun postalCode(postalCode: Optional) = postalCode(postalCode.getOrNull()) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** Street address of card acceptor. */ + fun streetAddress(streetAddress: String?) = + streetAddress(JsonField.ofNullable(streetAddress)) + + /** Alias for calling [Builder.streetAddress] with `streetAddress.orElse(null)`. */ + fun streetAddress(streetAddress: Optional) = + streetAddress(streetAddress.getOrNull()) + + /** + * Sets [Builder.streetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.streetAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streetAddress(streetAddress: JsonField) = apply { + this.streetAddress = streetAddress + } + + 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 [TransactionMerchant]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptorId() + * .acquiringInstitutionId() + * .city() + * .country() + * .descriptor() + * .mcc() + * .state() + * .phoneNumber() + * .postalCode() + * .streetAddress() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TransactionMerchant = + TransactionMerchant( + checkRequired("acceptorId", acceptorId), + checkRequired("acquiringInstitutionId", acquiringInstitutionId), + checkRequired("city", city), + checkRequired("country", country), + checkRequired("descriptor", descriptor), + checkRequired("mcc", mcc), + checkRequired("state", state), + checkRequired("phoneNumber", phoneNumber), + checkRequired("postalCode", postalCode), + checkRequired("streetAddress", streetAddress), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TransactionMerchant = apply { + if (validated) { + return@apply + } + + acceptorId() + acquiringInstitutionId() + city() + country() + descriptor() + mcc() + state() + phoneNumber() + postalCode() + streetAddress() + 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 (acceptorId.asKnown().isPresent) 1 else 0) + + (if (acquiringInstitutionId.asKnown().isPresent) 1 else 0) + + (if (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (if (mcc.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (streetAddress.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionMerchant && + acceptorId == other.acceptorId && + acquiringInstitutionId == other.acquiringInstitutionId && + city == other.city && + country == other.country && + descriptor == other.descriptor && + mcc == other.mcc && + state == other.state && + phoneNumber == other.phoneNumber && + postalCode == other.postalCode && + streetAddress == other.streetAddress && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptorId, + acquiringInstitutionId, + city, + country, + descriptor, + mcc, + state, + phoneNumber, + postalCode, + streetAddress, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionMerchant{acceptorId=$acceptorId, acquiringInstitutionId=$acquiringInstitutionId, city=$city, country=$country, descriptor=$descriptor, mcc=$mcc, state=$state, phoneNumber=$phoneNumber, postalCode=$postalCode, streetAddress=$streetAddress, additionalProperties=$additionalProperties}" + } + + /** + * Where the cardholder received the service, when different from the card acceptor location. + * This is populated from network data elements such as Mastercard DE-122 SE1 SF9-14 and Visa + * F34 DS02. + */ + class ServiceLocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val city: JsonField, + private val country: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val streetAddress: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("street_address") + @ExcludeMissing + streetAddress: JsonField = JsonMissing.of(), + ) : this(city, country, postalCode, state, streetAddress, mutableMapOf()) + + /** + * City of service location. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun city(): Optional = city.getOptional("city") + + /** + * Country code of service location, ISO 3166-1 alpha-3. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun country(): Optional = country.getOptional("country") + + /** + * Postal code of service location. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun postalCode(): Optional = postalCode.getOptional("postal_code") + + /** + * State/province code of service location, ISO 3166-2. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * Street address of service location. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streetAddress(): Optional = streetAddress.getOptional("street_address") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [postalCode]. + * + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [streetAddress]. + * + * Unlike [streetAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("street_address") + @ExcludeMissing + fun _streetAddress(): JsonField = streetAddress + + @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 [ServiceLocation]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .postalCode() + * .state() + * .streetAddress() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceLocation]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var streetAddress: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serviceLocation: ServiceLocation) = apply { + city = serviceLocation.city + country = serviceLocation.country + postalCode = serviceLocation.postalCode + state = serviceLocation.state + streetAddress = serviceLocation.streetAddress + additionalProperties = serviceLocation.additionalProperties.toMutableMap() + } + + /** City of service location. */ + fun city(city: String?) = city(JsonField.ofNullable(city)) + + /** Alias for calling [Builder.city] with `city.orElse(null)`. */ + fun city(city: Optional) = city(city.getOrNull()) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** Country code of service location, ISO 3166-1 alpha-3. */ + fun country(country: String?) = country(JsonField.ofNullable(country)) + + /** Alias for calling [Builder.country] with `country.orElse(null)`. */ + fun country(country: Optional) = country(country.getOrNull()) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** Postal code of service location. */ + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + /** Alias for calling [Builder.postalCode] with `postalCode.orElse(null)`. */ + fun postalCode(postalCode: Optional) = postalCode(postalCode.getOrNull()) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + /** State/province code of service location, ISO 3166-2. */ + fun state(state: String?) = state(JsonField.ofNullable(state)) + + /** Alias for calling [Builder.state] with `state.orElse(null)`. */ + fun state(state: Optional) = state(state.getOrNull()) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + /** Street address of service location. */ + fun streetAddress(streetAddress: String?) = + streetAddress(JsonField.ofNullable(streetAddress)) + + /** Alias for calling [Builder.streetAddress] with `streetAddress.orElse(null)`. */ + fun streetAddress(streetAddress: Optional) = + streetAddress(streetAddress.getOrNull()) + + /** + * Sets [Builder.streetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.streetAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streetAddress(streetAddress: JsonField) = apply { + this.streetAddress = streetAddress + } + + 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 [ServiceLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .postalCode() + * .state() + * .streetAddress() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceLocation = + ServiceLocation( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + checkRequired("streetAddress", streetAddress), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ServiceLocation = apply { + if (validated) { + return@apply + } + + city() + country() + postalCode() + state() + streetAddress() + 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 (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (postalCode.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + (if (streetAddress.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceLocation && + city == other.city && + country == other.country && + postalCode == other.postalCode && + state == other.state && + streetAddress == other.streetAddress && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, postalCode, state, streetAddress, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServiceLocation{city=$city, country=$country, postalCode=$postalCode, state=$state, streetAddress=$streetAddress, additionalProperties=$additionalProperties}" + } + + /** + * The type of authorization request that this request is for. Note that `CREDIT_AUTHORIZATION` + * and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to users with credit decisioning via + * ASA enabled. + */ + class AsaRequestStatus @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 AUTHORIZATION = of("AUTHORIZATION") + + @JvmField val CREDIT_AUTHORIZATION = of("CREDIT_AUTHORIZATION") + + @JvmField val FINANCIAL_AUTHORIZATION = of("FINANCIAL_AUTHORIZATION") + + @JvmField val FINANCIAL_CREDIT_AUTHORIZATION = of("FINANCIAL_CREDIT_AUTHORIZATION") + + @JvmField val BALANCE_INQUIRY = of("BALANCE_INQUIRY") + + @JvmStatic fun of(value: String) = AsaRequestStatus(JsonField.of(value)) + } + + /** An enum containing [AsaRequestStatus]'s known values. */ + enum class Known { + AUTHORIZATION, + CREDIT_AUTHORIZATION, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + BALANCE_INQUIRY, + } + + /** + * An enum containing [AsaRequestStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AsaRequestStatus] 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 { + AUTHORIZATION, + CREDIT_AUTHORIZATION, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + BALANCE_INQUIRY, + /** + * An enum member indicating that [AsaRequestStatus] 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) { + AUTHORIZATION -> Value.AUTHORIZATION + CREDIT_AUTHORIZATION -> Value.CREDIT_AUTHORIZATION + FINANCIAL_AUTHORIZATION -> Value.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Value.FINANCIAL_CREDIT_AUTHORIZATION + BALANCE_INQUIRY -> Value.BALANCE_INQUIRY + 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) { + AUTHORIZATION -> Known.AUTHORIZATION + CREDIT_AUTHORIZATION -> Known.CREDIT_AUTHORIZATION + FINANCIAL_AUTHORIZATION -> Known.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Known.FINANCIAL_CREDIT_AUTHORIZATION + BALANCE_INQUIRY -> Known.BALANCE_INQUIRY + else -> throw LithicInvalidDataException("Unknown AsaRequestStatus: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaRequestStatus = 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 AsaRequestStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The entity that initiated the transaction. */ + class TransactionInitiator + @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 CARDHOLDER = of("CARDHOLDER") + + @JvmField val MERCHANT = of("MERCHANT") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = TransactionInitiator(JsonField.of(value)) + } + + /** An enum containing [TransactionInitiator]'s known values. */ + enum class Known { + CARDHOLDER, + MERCHANT, + UNKNOWN, + } + + /** + * An enum containing [TransactionInitiator]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionInitiator] 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 { + CARDHOLDER, + MERCHANT, + UNKNOWN, + /** + * An enum member indicating that [TransactionInitiator] 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) { + CARDHOLDER -> Value.CARDHOLDER + MERCHANT -> Value.MERCHANT + UNKNOWN -> Value.UNKNOWN + 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) { + CARDHOLDER -> Known.CARDHOLDER + MERCHANT -> Known.MERCHANT + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown TransactionInitiator: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TransactionInitiator = 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 TransactionInitiator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AccountType @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 CHECKING = of("CHECKING") + + @JvmField val SAVINGS = of("SAVINGS") + + @JvmStatic fun of(value: String) = AccountType(JsonField.of(value)) + } + + /** An enum containing [AccountType]'s known values. */ + enum class Known { + CHECKING, + SAVINGS, + } + + /** + * An enum containing [AccountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AccountType] 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 { + CHECKING, + SAVINGS, + /** + * An enum member indicating that [AccountType] 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) { + CHECKING -> Value.CHECKING + SAVINGS -> Value.SAVINGS + 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) { + CHECKING -> Known.CHECKING + SAVINGS -> Known.SAVINGS + else -> throw LithicInvalidDataException("Unknown AccountType: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AccountType = 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 AccountType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Optional Object containing information if the Card is a part of a Fleet managed program */ + class AsaRequestFleetInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fleetPromptCode: JsonField, + private val fleetRestrictionCode: JsonField, + private val driverNumber: JsonField, + private val vehicleNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fleet_prompt_code") + @ExcludeMissing + fleetPromptCode: JsonField = JsonMissing.of(), + @JsonProperty("fleet_restriction_code") + @ExcludeMissing + fleetRestrictionCode: JsonField = JsonMissing.of(), + @JsonProperty("driver_number") + @ExcludeMissing + driverNumber: JsonField = JsonMissing.of(), + @JsonProperty("vehicle_number") + @ExcludeMissing + vehicleNumber: JsonField = JsonMissing.of(), + ) : this(fleetPromptCode, fleetRestrictionCode, driverNumber, vehicleNumber, mutableMapOf()) + + /** + * Code indicating what the driver was prompted to enter at time of purchase. This is + * configured at a program level and is a static configuration, and does not change on a + * request to request basis + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fleetPromptCode(): FleetPromptCode = fleetPromptCode.getRequired("fleet_prompt_code") + + /** + * Code indicating which restrictions, if any, there are on purchase. This is configured at + * a program level and is a static configuration, and does not change on a request to + * request basis + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fleetRestrictionCode(): FleetRestrictionCode = + fleetRestrictionCode.getRequired("fleet_restriction_code") + + /** + * Number representing the driver + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun driverNumber(): Optional = driverNumber.getOptional("driver_number") + + /** + * Number associated with the vehicle + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vehicleNumber(): Optional = vehicleNumber.getOptional("vehicle_number") + + /** + * Returns the raw JSON value of [fleetPromptCode]. + * + * Unlike [fleetPromptCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fleet_prompt_code") + @ExcludeMissing + fun _fleetPromptCode(): JsonField = fleetPromptCode + + /** + * Returns the raw JSON value of [fleetRestrictionCode]. + * + * Unlike [fleetRestrictionCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fleet_restriction_code") + @ExcludeMissing + fun _fleetRestrictionCode(): JsonField = fleetRestrictionCode + + /** + * Returns the raw JSON value of [driverNumber]. + * + * Unlike [driverNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("driver_number") + @ExcludeMissing + fun _driverNumber(): JsonField = driverNumber + + /** + * Returns the raw JSON value of [vehicleNumber]. + * + * Unlike [vehicleNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("vehicle_number") + @ExcludeMissing + fun _vehicleNumber(): JsonField = vehicleNumber + + @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 [AsaRequestFleetInfo]. + * + * The following fields are required: + * ```java + * .fleetPromptCode() + * .fleetRestrictionCode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaRequestFleetInfo]. */ + class Builder internal constructor() { + + private var fleetPromptCode: JsonField? = null + private var fleetRestrictionCode: JsonField? = null + private var driverNumber: JsonField = JsonMissing.of() + private var vehicleNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaRequestFleetInfo: AsaRequestFleetInfo) = apply { + fleetPromptCode = asaRequestFleetInfo.fleetPromptCode + fleetRestrictionCode = asaRequestFleetInfo.fleetRestrictionCode + driverNumber = asaRequestFleetInfo.driverNumber + vehicleNumber = asaRequestFleetInfo.vehicleNumber + additionalProperties = asaRequestFleetInfo.additionalProperties.toMutableMap() + } + + /** + * Code indicating what the driver was prompted to enter at time of purchase. This is + * configured at a program level and is a static configuration, and does not change on a + * request to request basis + */ + fun fleetPromptCode(fleetPromptCode: FleetPromptCode) = + fleetPromptCode(JsonField.of(fleetPromptCode)) + + /** + * Sets [Builder.fleetPromptCode] to an arbitrary JSON value. + * + * You should usually call [Builder.fleetPromptCode] with a well-typed [FleetPromptCode] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun fleetPromptCode(fleetPromptCode: JsonField) = apply { + this.fleetPromptCode = fleetPromptCode + } + + /** + * Code indicating which restrictions, if any, there are on purchase. This is configured + * at a program level and is a static configuration, and does not change on a request to + * request basis + */ + fun fleetRestrictionCode(fleetRestrictionCode: FleetRestrictionCode) = + fleetRestrictionCode(JsonField.of(fleetRestrictionCode)) + + /** + * Sets [Builder.fleetRestrictionCode] to an arbitrary JSON value. + * + * You should usually call [Builder.fleetRestrictionCode] with a well-typed + * [FleetRestrictionCode] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun fleetRestrictionCode(fleetRestrictionCode: JsonField) = + apply { + this.fleetRestrictionCode = fleetRestrictionCode + } + + /** Number representing the driver */ + fun driverNumber(driverNumber: String?) = + driverNumber(JsonField.ofNullable(driverNumber)) + + /** Alias for calling [Builder.driverNumber] with `driverNumber.orElse(null)`. */ + fun driverNumber(driverNumber: Optional) = + driverNumber(driverNumber.getOrNull()) + + /** + * Sets [Builder.driverNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.driverNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun driverNumber(driverNumber: JsonField) = apply { + this.driverNumber = driverNumber + } + + /** Number associated with the vehicle */ + fun vehicleNumber(vehicleNumber: String?) = + vehicleNumber(JsonField.ofNullable(vehicleNumber)) + + /** Alias for calling [Builder.vehicleNumber] with `vehicleNumber.orElse(null)`. */ + fun vehicleNumber(vehicleNumber: Optional) = + vehicleNumber(vehicleNumber.getOrNull()) + + /** + * Sets [Builder.vehicleNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.vehicleNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vehicleNumber(vehicleNumber: JsonField) = apply { + this.vehicleNumber = vehicleNumber + } + + 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 [AsaRequestFleetInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fleetPromptCode() + * .fleetRestrictionCode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AsaRequestFleetInfo = + AsaRequestFleetInfo( + checkRequired("fleetPromptCode", fleetPromptCode), + checkRequired("fleetRestrictionCode", fleetRestrictionCode), + driverNumber, + vehicleNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaRequestFleetInfo = apply { + if (validated) { + return@apply + } + + fleetPromptCode().validate() + fleetRestrictionCode().validate() + driverNumber() + vehicleNumber() + 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 = + (fleetPromptCode.asKnown().getOrNull()?.validity() ?: 0) + + (fleetRestrictionCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (driverNumber.asKnown().isPresent) 1 else 0) + + (if (vehicleNumber.asKnown().isPresent) 1 else 0) + + /** + * Code indicating what the driver was prompted to enter at time of purchase. This is + * configured at a program level and is a static configuration, and does not change on a + * request to request basis + */ + class FleetPromptCode + @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 NO_PROMPT = of("NO_PROMPT") + + @JvmField val VEHICLE_NUMBER = of("VEHICLE_NUMBER") + + @JvmField val DRIVER_NUMBER = of("DRIVER_NUMBER") + + @JvmStatic fun of(value: String) = FleetPromptCode(JsonField.of(value)) + } + + /** An enum containing [FleetPromptCode]'s known values. */ + enum class Known { + NO_PROMPT, + VEHICLE_NUMBER, + DRIVER_NUMBER, + } + + /** + * An enum containing [FleetPromptCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FleetPromptCode] 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 { + NO_PROMPT, + VEHICLE_NUMBER, + DRIVER_NUMBER, + /** + * An enum member indicating that [FleetPromptCode] 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) { + NO_PROMPT -> Value.NO_PROMPT + VEHICLE_NUMBER -> Value.VEHICLE_NUMBER + DRIVER_NUMBER -> Value.DRIVER_NUMBER + 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) { + NO_PROMPT -> Known.NO_PROMPT + VEHICLE_NUMBER -> Known.VEHICLE_NUMBER + DRIVER_NUMBER -> Known.DRIVER_NUMBER + else -> throw LithicInvalidDataException("Unknown FleetPromptCode: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FleetPromptCode = 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 FleetPromptCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Code indicating which restrictions, if any, there are on purchase. This is configured at + * a program level and is a static configuration, and does not change on a request to + * request basis + */ + class FleetRestrictionCode + @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 NO_RESTRICTIONS = of("NO_RESTRICTIONS") + + @JvmField val FUEL_ONLY = of("FUEL_ONLY") + + @JvmStatic fun of(value: String) = FleetRestrictionCode(JsonField.of(value)) + } + + /** An enum containing [FleetRestrictionCode]'s known values. */ + enum class Known { + NO_RESTRICTIONS, + FUEL_ONLY, + } + + /** + * An enum containing [FleetRestrictionCode]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [FleetRestrictionCode] 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 { + NO_RESTRICTIONS, + FUEL_ONLY, + /** + * An enum member indicating that [FleetRestrictionCode] 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) { + NO_RESTRICTIONS -> Value.NO_RESTRICTIONS + FUEL_ONLY -> Value.FUEL_ONLY + 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) { + NO_RESTRICTIONS -> Known.NO_RESTRICTIONS + FUEL_ONLY -> Known.FUEL_ONLY + else -> throw LithicInvalidDataException("Unknown FleetRestrictionCode: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FleetRestrictionCode = 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 FleetRestrictionCode && 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 AsaRequestFleetInfo && + fleetPromptCode == other.fleetPromptCode && + fleetRestrictionCode == other.fleetRestrictionCode && + driverNumber == other.driverNumber && + vehicleNumber == other.vehicleNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + fleetPromptCode, + fleetRestrictionCode, + driverNumber, + vehicleNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaRequestFleetInfo{fleetPromptCode=$fleetPromptCode, fleetRestrictionCode=$fleetRestrictionCode, driverNumber=$driverNumber, vehicleNumber=$vehicleNumber, additionalProperties=$additionalProperties}" + } + + /** The latest Authorization Challenge that was issued to the cardholder for this merchant. */ + class LatestChallenge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val phoneNumber: JsonField, + private val status: JsonField, + private val completedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("completed_at") + @ExcludeMissing + completedAt: JsonField = JsonMissing.of(), + ) : this(phoneNumber, status, completedAt, mutableMapOf()) + + /** + * The phone number used for sending Authorization Challenge SMS. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun phoneNumber(): String = phoneNumber.getRequired("phone_number") + + /** + * The status of the Authorization Challenge + * * `COMPLETED` - Challenge was successfully completed by the cardholder + * * `PENDING` - Challenge is still open + * * `EXPIRED` - Challenge has expired without being completed + * * `ERROR` - There was an error processing the challenge + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * The date and time when the Authorization Challenge was completed in UTC. Present only if + * the status is `COMPLETED`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun completedAt(): Optional = completedAt.getOptional("completed_at") + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * 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 [completedAt]. + * + * Unlike [completedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completed_at") + @ExcludeMissing + fun _completedAt(): JsonField = completedAt + + @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 [LatestChallenge]. + * + * The following fields are required: + * ```java + * .phoneNumber() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LatestChallenge]. */ + class Builder internal constructor() { + + private var phoneNumber: JsonField? = null + private var status: JsonField? = null + private var completedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(latestChallenge: LatestChallenge) = apply { + phoneNumber = latestChallenge.phoneNumber + status = latestChallenge.status + completedAt = latestChallenge.completedAt + additionalProperties = latestChallenge.additionalProperties.toMutableMap() + } + + /** The phone number used for sending Authorization Challenge SMS. */ + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } + + /** + * The status of the Authorization Challenge + * * `COMPLETED` - Challenge was successfully completed by the cardholder + * * `PENDING` - Challenge is still open + * * `EXPIRED` - Challenge has expired without being completed + * * `ERROR` - There was an error processing the challenge + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** + * The date and time when the Authorization Challenge was completed in UTC. Present only + * if the status is `COMPLETED`. + */ + fun completedAt(completedAt: OffsetDateTime) = completedAt(JsonField.of(completedAt)) + + /** + * Sets [Builder.completedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.completedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun completedAt(completedAt: JsonField) = apply { + this.completedAt = completedAt + } + + 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 [LatestChallenge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .phoneNumber() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LatestChallenge = + LatestChallenge( + checkRequired("phoneNumber", phoneNumber), + checkRequired("status", status), + completedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LatestChallenge = apply { + if (validated) { + return@apply + } + + phoneNumber() + status().validate() + completedAt() + 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 (phoneNumber.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (completedAt.asKnown().isPresent) 1 else 0) + + /** + * The status of the Authorization Challenge + * * `COMPLETED` - Challenge was successfully completed by the cardholder + * * `PENDING` - Challenge is still open + * * `EXPIRED` - Challenge has expired without being completed + * * `ERROR` - There was an error processing the challenge + */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val EXPIRED = of("EXPIRED") + + @JvmField val ERROR = of("ERROR") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + COMPLETED, + PENDING, + EXPIRED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMPLETED, + PENDING, + EXPIRED, + ERROR, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMPLETED -> Value.COMPLETED + PENDING -> Value.PENDING + EXPIRED -> Value.EXPIRED + ERROR -> Value.ERROR + 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) { + COMPLETED -> Known.COMPLETED + PENDING -> Known.PENDING + EXPIRED -> Known.EXPIRED + ERROR -> Known.ERROR + else -> throw LithicInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && 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 LatestChallenge && + phoneNumber == other.phoneNumber && + status == other.status && + completedAt == other.completedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(phoneNumber, status, completedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LatestChallenge{phoneNumber=$phoneNumber, status=$status, completedAt=$completedAt, additionalProperties=$additionalProperties}" + } + + /** Card network of the authorization. */ + class Network @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 AMEX = of("AMEX") + + @JvmField val INTERLINK = of("INTERLINK") + + @JvmField val MAESTRO = of("MAESTRO") + + @JvmField val MASTERCARD = of("MASTERCARD") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmField val VISA = of("VISA") + + @JvmStatic fun of(value: String) = Network(JsonField.of(value)) + } + + /** An enum containing [Network]'s known values. */ + enum class Known { + AMEX, + INTERLINK, + MAESTRO, + MASTERCARD, + UNKNOWN, + VISA, + } + + /** + * An enum containing [Network]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Network] 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 { + AMEX, + INTERLINK, + MAESTRO, + MASTERCARD, + UNKNOWN, + VISA, + /** An enum member indicating that [Network] 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) { + AMEX -> Value.AMEX + INTERLINK -> Value.INTERLINK + MAESTRO -> Value.MAESTRO + MASTERCARD -> Value.MASTERCARD + UNKNOWN -> Value.UNKNOWN + VISA -> Value.VISA + 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) { + AMEX -> Known.AMEX + INTERLINK -> Known.INTERLINK + MAESTRO -> Known.MAESTRO + MASTERCARD -> Known.MASTERCARD + UNKNOWN -> Known.UNKNOWN + VISA -> Known.VISA + else -> throw LithicInvalidDataException("Unknown Network: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Network = 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 Network && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Contains raw data provided by the card network, including attributes that provide further + * context about the authorization. If populated by the network, data is organized by Lithic and + * passed through without further modification. Please consult the official network + * documentation for more details about these values and how to use them. This object is only + * available to certain programs- contact your Customer Success Manager to discuss enabling + * access. + */ + class AsaNetworkSpecificData + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val mastercard: JsonField, + private val visa: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("mastercard") + @ExcludeMissing + mastercard: JsonField = JsonMissing.of(), + @JsonProperty("visa") + @ExcludeMissing + visa: JsonField = JsonMissing.of(), + ) : this(mastercard, visa, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mastercard(): Optional = + mastercard.getOptional("mastercard") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun visa(): Optional = visa.getOptional("visa") + + /** + * Returns the raw JSON value of [mastercard]. + * + * Unlike [mastercard], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mastercard") + @ExcludeMissing + fun _mastercard(): JsonField = mastercard + + /** + * Returns the raw JSON value of [visa]. + * + * Unlike [visa], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("visa") + @ExcludeMissing + fun _visa(): JsonField = visa + + @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 [AsaNetworkSpecificData]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaNetworkSpecificData]. */ + class Builder internal constructor() { + + private var mastercard: JsonField = JsonMissing.of() + private var visa: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaNetworkSpecificData: AsaNetworkSpecificData) = apply { + mastercard = asaNetworkSpecificData.mastercard + visa = asaNetworkSpecificData.visa + additionalProperties = asaNetworkSpecificData.additionalProperties.toMutableMap() + } + + fun mastercard(mastercard: AsaNetworkSpecificDataMastercard?) = + mastercard(JsonField.ofNullable(mastercard)) + + /** Alias for calling [Builder.mastercard] with `mastercard.orElse(null)`. */ + fun mastercard(mastercard: Optional) = + mastercard(mastercard.getOrNull()) + + /** + * Sets [Builder.mastercard] to an arbitrary JSON value. + * + * You should usually call [Builder.mastercard] with a well-typed + * [AsaNetworkSpecificDataMastercard] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun mastercard(mastercard: JsonField) = apply { + this.mastercard = mastercard + } + + fun visa(visa: AsaNetworkSpecificDataVisa?) = visa(JsonField.ofNullable(visa)) + + /** Alias for calling [Builder.visa] with `visa.orElse(null)`. */ + fun visa(visa: Optional) = visa(visa.getOrNull()) + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [AsaNetworkSpecificDataVisa] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun visa(visa: JsonField) = apply { this.visa = visa } + + 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 [AsaNetworkSpecificData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AsaNetworkSpecificData = + AsaNetworkSpecificData(mastercard, visa, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaNetworkSpecificData = apply { + if (validated) { + return@apply + } + + mastercard().ifPresent { it.validate() } + visa().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (mastercard.asKnown().getOrNull()?.validity() ?: 0) + + (visa.asKnown().getOrNull()?.validity() ?: 0) + + class AsaNetworkSpecificDataMastercard + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val ecommerceSecurityLevelIndicator: JsonField, + private val onBehalfServiceResult: JsonField>, + private val transactionTypeIdentifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ecommerce_security_level_indicator") + @ExcludeMissing + ecommerceSecurityLevelIndicator: JsonField = JsonMissing.of(), + @JsonProperty("on_behalf_service_result") + @ExcludeMissing + onBehalfServiceResult: JsonField> = JsonMissing.of(), + @JsonProperty("transaction_type_identifier") + @ExcludeMissing + transactionTypeIdentifier: JsonField = JsonMissing.of(), + ) : this( + ecommerceSecurityLevelIndicator, + onBehalfServiceResult, + transactionTypeIdentifier, + mutableMapOf(), + ) + + /** + * Indicates the electronic commerce security level and UCAF collection. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun ecommerceSecurityLevelIndicator(): Optional = + ecommerceSecurityLevelIndicator.getOptional("ecommerce_security_level_indicator") + + /** + * The On-behalf Service performed on the transaction and the results. Contains all + * applicable, on-behalf service results that were performed on a given transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun onBehalfServiceResult(): Optional> = + onBehalfServiceResult.getOptional("on_behalf_service_result") + + /** + * Indicates the type of additional transaction purpose. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transactionTypeIdentifier(): Optional = + transactionTypeIdentifier.getOptional("transaction_type_identifier") + + /** + * Returns the raw JSON value of [ecommerceSecurityLevelIndicator]. + * + * Unlike [ecommerceSecurityLevelIndicator], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("ecommerce_security_level_indicator") + @ExcludeMissing + fun _ecommerceSecurityLevelIndicator(): JsonField = + ecommerceSecurityLevelIndicator + + /** + * Returns the raw JSON value of [onBehalfServiceResult]. + * + * Unlike [onBehalfServiceResult], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_behalf_service_result") + @ExcludeMissing + fun _onBehalfServiceResult(): JsonField> = + onBehalfServiceResult + + /** + * Returns the raw JSON value of [transactionTypeIdentifier]. + * + * Unlike [transactionTypeIdentifier], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("transaction_type_identifier") + @ExcludeMissing + fun _transactionTypeIdentifier(): JsonField = transactionTypeIdentifier + + @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 + * [AsaNetworkSpecificDataMastercard]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaNetworkSpecificDataMastercard]. */ + class Builder internal constructor() { + + private var ecommerceSecurityLevelIndicator: JsonField = JsonMissing.of() + private var onBehalfServiceResult: JsonField>? = + null + private var transactionTypeIdentifier: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + asaNetworkSpecificDataMastercard: AsaNetworkSpecificDataMastercard + ) = apply { + ecommerceSecurityLevelIndicator = + asaNetworkSpecificDataMastercard.ecommerceSecurityLevelIndicator + onBehalfServiceResult = + asaNetworkSpecificDataMastercard.onBehalfServiceResult.map { + it.toMutableList() + } + transactionTypeIdentifier = + asaNetworkSpecificDataMastercard.transactionTypeIdentifier + additionalProperties = + asaNetworkSpecificDataMastercard.additionalProperties.toMutableMap() + } + + /** Indicates the electronic commerce security level and UCAF collection. */ + fun ecommerceSecurityLevelIndicator(ecommerceSecurityLevelIndicator: String?) = + ecommerceSecurityLevelIndicator( + JsonField.ofNullable(ecommerceSecurityLevelIndicator) + ) + + /** + * Alias for calling [Builder.ecommerceSecurityLevelIndicator] with + * `ecommerceSecurityLevelIndicator.orElse(null)`. + */ + fun ecommerceSecurityLevelIndicator( + ecommerceSecurityLevelIndicator: Optional + ) = ecommerceSecurityLevelIndicator(ecommerceSecurityLevelIndicator.getOrNull()) + + /** + * Sets [Builder.ecommerceSecurityLevelIndicator] to an arbitrary JSON value. + * + * You should usually call [Builder.ecommerceSecurityLevelIndicator] with a + * well-typed [String] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun ecommerceSecurityLevelIndicator( + ecommerceSecurityLevelIndicator: JsonField + ) = apply { this.ecommerceSecurityLevelIndicator = ecommerceSecurityLevelIndicator } + + /** + * The On-behalf Service performed on the transaction and the results. Contains all + * applicable, on-behalf service results that were performed on a given transaction. + */ + fun onBehalfServiceResult(onBehalfServiceResult: List?) = + onBehalfServiceResult(JsonField.ofNullable(onBehalfServiceResult)) + + /** + * Alias for calling [Builder.onBehalfServiceResult] with + * `onBehalfServiceResult.orElse(null)`. + */ + fun onBehalfServiceResult( + onBehalfServiceResult: Optional> + ) = onBehalfServiceResult(onBehalfServiceResult.getOrNull()) + + /** + * Sets [Builder.onBehalfServiceResult] to an arbitrary JSON value. + * + * You should usually call [Builder.onBehalfServiceResult] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun onBehalfServiceResult( + onBehalfServiceResult: JsonField> + ) = apply { + this.onBehalfServiceResult = onBehalfServiceResult.map { it.toMutableList() } + } + + /** + * Adds a single [OnBehalfServiceResult] to [Builder.onBehalfServiceResult]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOnBehalfServiceResult(onBehalfServiceResult: OnBehalfServiceResult) = apply { + this.onBehalfServiceResult = + (this.onBehalfServiceResult ?: JsonField.of(mutableListOf())).also { + checkKnown("onBehalfServiceResult", it).add(onBehalfServiceResult) + } + } + + /** Indicates the type of additional transaction purpose. */ + fun transactionTypeIdentifier(transactionTypeIdentifier: String?) = + transactionTypeIdentifier(JsonField.ofNullable(transactionTypeIdentifier)) + + /** + * Alias for calling [Builder.transactionTypeIdentifier] with + * `transactionTypeIdentifier.orElse(null)`. + */ + fun transactionTypeIdentifier(transactionTypeIdentifier: Optional) = + transactionTypeIdentifier(transactionTypeIdentifier.getOrNull()) + + /** + * Sets [Builder.transactionTypeIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionTypeIdentifier] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun transactionTypeIdentifier(transactionTypeIdentifier: JsonField) = + apply { + this.transactionTypeIdentifier = transactionTypeIdentifier + } + + 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 [AsaNetworkSpecificDataMastercard]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AsaNetworkSpecificDataMastercard = + AsaNetworkSpecificDataMastercard( + ecommerceSecurityLevelIndicator, + (onBehalfServiceResult ?: JsonMissing.of()).map { it.toImmutable() }, + transactionTypeIdentifier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaNetworkSpecificDataMastercard = apply { + if (validated) { + return@apply + } + + ecommerceSecurityLevelIndicator() + onBehalfServiceResult().ifPresent { it.forEach { it.validate() } } + transactionTypeIdentifier() + 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 (ecommerceSecurityLevelIndicator.asKnown().isPresent) 1 else 0) + + (onBehalfServiceResult.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (transactionTypeIdentifier.asKnown().isPresent) 1 else 0) + + class OnBehalfServiceResult + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val result1: JsonField, + private val result2: JsonField, + private val service: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("result_1") + @ExcludeMissing + result1: JsonField = JsonMissing.of(), + @JsonProperty("result_2") + @ExcludeMissing + result2: JsonField = JsonMissing.of(), + @JsonProperty("service") + @ExcludeMissing + service: JsonField = JsonMissing.of(), + ) : this(result1, result2, service, mutableMapOf()) + + /** + * Indicates the results of the service processing. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun result1(): String = result1.getRequired("result_1") + + /** + * Identifies the results of the service processing. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun result2(): String = result2.getRequired("result_2") + + /** + * Indicates the service performed on 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 service(): String = service.getRequired("service") + + /** + * Returns the raw JSON value of [result1]. + * + * Unlike [result1], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("result_1") + @ExcludeMissing + fun _result1(): JsonField = result1 + + /** + * Returns the raw JSON value of [result2]. + * + * Unlike [result2], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("result_2") + @ExcludeMissing + fun _result2(): JsonField = result2 + + /** + * Returns the raw JSON value of [service]. + * + * Unlike [service], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("service") @ExcludeMissing fun _service(): JsonField = service + + @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 + * [OnBehalfServiceResult]. + * + * The following fields are required: + * ```java + * .result1() + * .result2() + * .service() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnBehalfServiceResult]. */ + class Builder internal constructor() { + + private var result1: JsonField? = null + private var result2: JsonField? = null + private var service: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(onBehalfServiceResult: OnBehalfServiceResult) = apply { + result1 = onBehalfServiceResult.result1 + result2 = onBehalfServiceResult.result2 + service = onBehalfServiceResult.service + additionalProperties = + onBehalfServiceResult.additionalProperties.toMutableMap() + } + + /** Indicates the results of the service processing. */ + fun result1(result1: String) = result1(JsonField.of(result1)) + + /** + * Sets [Builder.result1] to an arbitrary JSON value. + * + * You should usually call [Builder.result1] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun result1(result1: JsonField) = apply { this.result1 = result1 } + + /** Identifies the results of the service processing. */ + fun result2(result2: String) = result2(JsonField.of(result2)) + + /** + * Sets [Builder.result2] to an arbitrary JSON value. + * + * You should usually call [Builder.result2] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun result2(result2: JsonField) = apply { this.result2 = result2 } + + /** Indicates the service performed on the transaction. */ + fun service(service: String) = service(JsonField.of(service)) + + /** + * Sets [Builder.service] to an arbitrary JSON value. + * + * You should usually call [Builder.service] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun service(service: JsonField) = apply { this.service = service } + + 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 [OnBehalfServiceResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .result1() + * .result2() + * .service() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OnBehalfServiceResult = + OnBehalfServiceResult( + checkRequired("result1", result1), + checkRequired("result2", result2), + checkRequired("service", service), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): OnBehalfServiceResult = apply { + if (validated) { + return@apply + } + + result1() + result2() + service() + 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 (result1.asKnown().isPresent) 1 else 0) + + (if (result2.asKnown().isPresent) 1 else 0) + + (if (service.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnBehalfServiceResult && + result1 == other.result1 && + result2 == other.result2 && + service == other.service && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(result1, result2, service, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnBehalfServiceResult{result1=$result1, result2=$result2, service=$service, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsaNetworkSpecificDataMastercard && + ecommerceSecurityLevelIndicator == other.ecommerceSecurityLevelIndicator && + onBehalfServiceResult == other.onBehalfServiceResult && + transactionTypeIdentifier == other.transactionTypeIdentifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + ecommerceSecurityLevelIndicator, + onBehalfServiceResult, + transactionTypeIdentifier, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaNetworkSpecificDataMastercard{ecommerceSecurityLevelIndicator=$ecommerceSecurityLevelIndicator, onBehalfServiceResult=$onBehalfServiceResult, transactionTypeIdentifier=$transactionTypeIdentifier, additionalProperties=$additionalProperties}" + } + + class AsaNetworkSpecificDataVisa + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val businessApplicationIdentifier: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("business_application_identifier") + @ExcludeMissing + businessApplicationIdentifier: JsonField = JsonMissing.of() + ) : this(businessApplicationIdentifier, mutableMapOf()) + + /** + * Identifies the purpose or category of a transaction, used to classify and process + * transactions according to Visa’s rules. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun businessApplicationIdentifier(): Optional = + businessApplicationIdentifier.getOptional("business_application_identifier") + + /** + * Returns the raw JSON value of [businessApplicationIdentifier]. + * + * Unlike [businessApplicationIdentifier], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("business_application_identifier") + @ExcludeMissing + fun _businessApplicationIdentifier(): JsonField = businessApplicationIdentifier + + @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 + * [AsaNetworkSpecificDataVisa]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaNetworkSpecificDataVisa]. */ + class Builder internal constructor() { + + private var businessApplicationIdentifier: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaNetworkSpecificDataVisa: AsaNetworkSpecificDataVisa) = apply { + businessApplicationIdentifier = + asaNetworkSpecificDataVisa.businessApplicationIdentifier + additionalProperties = + asaNetworkSpecificDataVisa.additionalProperties.toMutableMap() + } + + /** + * Identifies the purpose or category of a transaction, used to classify and process + * transactions according to Visa’s rules. + */ + fun businessApplicationIdentifier(businessApplicationIdentifier: String?) = + businessApplicationIdentifier( + JsonField.ofNullable(businessApplicationIdentifier) + ) + + /** + * Alias for calling [Builder.businessApplicationIdentifier] with + * `businessApplicationIdentifier.orElse(null)`. + */ + fun businessApplicationIdentifier(businessApplicationIdentifier: Optional) = + businessApplicationIdentifier(businessApplicationIdentifier.getOrNull()) + + /** + * Sets [Builder.businessApplicationIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.businessApplicationIdentifier] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun businessApplicationIdentifier( + businessApplicationIdentifier: JsonField + ) = apply { this.businessApplicationIdentifier = businessApplicationIdentifier } + + 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 [AsaNetworkSpecificDataVisa]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AsaNetworkSpecificDataVisa = + AsaNetworkSpecificDataVisa( + businessApplicationIdentifier, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaNetworkSpecificDataVisa = apply { + if (validated) { + return@apply + } + + businessApplicationIdentifier() + 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 (businessApplicationIdentifier.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsaNetworkSpecificDataVisa && + businessApplicationIdentifier == other.businessApplicationIdentifier && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(businessApplicationIdentifier, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaNetworkSpecificDataVisa{businessApplicationIdentifier=$businessApplicationIdentifier, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsaNetworkSpecificData && + mastercard == other.mastercard && + visa == other.visa && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(mastercard, visa, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaNetworkSpecificData{mastercard=$mastercard, visa=$visa, additionalProperties=$additionalProperties}" + } + + class Pos + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entryMode: JsonField, + private val terminal: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entry_mode") + @ExcludeMissing + entryMode: JsonField = JsonMissing.of(), + @JsonProperty("terminal") + @ExcludeMissing + terminal: JsonField = JsonMissing.of(), + ) : this(entryMode, terminal, mutableMapOf()) + + /** + * POS > Entry Mode object in ASA + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entryMode(): Optional = entryMode.getOptional("entry_mode") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun terminal(): Optional = terminal.getOptional("terminal") + + /** + * Returns the raw JSON value of [entryMode]. + * + * Unlike [entryMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entry_mode") + @ExcludeMissing + fun _entryMode(): JsonField = entryMode + + /** + * Returns the raw JSON value of [terminal]. + * + * Unlike [terminal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("terminal") + @ExcludeMissing + fun _terminal(): JsonField = terminal + + @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 [Pos]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Pos]. */ + class Builder internal constructor() { + + private var entryMode: JsonField = JsonMissing.of() + private var terminal: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pos: Pos) = apply { + entryMode = pos.entryMode + terminal = pos.terminal + additionalProperties = pos.additionalProperties.toMutableMap() + } + + /** POS > Entry Mode object in ASA */ + fun entryMode(entryMode: AsaRequestPosEntryMode) = entryMode(JsonField.of(entryMode)) + + /** + * Sets [Builder.entryMode] to an arbitrary JSON value. + * + * You should usually call [Builder.entryMode] with a well-typed + * [AsaRequestPosEntryMode] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun entryMode(entryMode: JsonField) = apply { + this.entryMode = entryMode + } + + fun terminal(terminal: AsaPosTerminal) = terminal(JsonField.of(terminal)) + + /** + * Sets [Builder.terminal] to an arbitrary JSON value. + * + * You should usually call [Builder.terminal] with a well-typed [AsaPosTerminal] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun terminal(terminal: JsonField) = apply { this.terminal = terminal } + + 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 [Pos]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Pos = Pos(entryMode, terminal, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Pos = apply { + if (validated) { + return@apply + } + + entryMode().ifPresent { it.validate() } + terminal().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (entryMode.asKnown().getOrNull()?.validity() ?: 0) + + (terminal.asKnown().getOrNull()?.validity() ?: 0) + + /** POS > Entry Mode object in ASA */ + class AsaRequestPosEntryMode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val card: JsonField, + private val cardholder: JsonField, + private val pan: JsonField, + private val pinEntered: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("card") @ExcludeMissing card: JsonField = JsonMissing.of(), + @JsonProperty("cardholder") + @ExcludeMissing + cardholder: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + @JsonProperty("pin_entered") + @ExcludeMissing + pinEntered: JsonField = JsonMissing.of(), + ) : this(card, cardholder, pan, pinEntered, mutableMapOf()) + + /** + * Card Presence Indicator + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun card(): Optional = card.getOptional("card") + + /** + * Cardholder Presence Indicator + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun cardholder(): Optional = cardholder.getOptional("cardholder") + + /** + * Method of entry for the PAN + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pan(): Optional = pan.getOptional("pan") + + /** + * Indicates whether the cardholder entered the PIN. True if the PIN was entered. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pinEntered(): Optional = pinEntered.getOptional("pin_entered") + + /** + * Returns the raw JSON value of [card]. + * + * Unlike [card], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card") @ExcludeMissing fun _card(): JsonField = card + + /** + * Returns the raw JSON value of [cardholder]. + * + * Unlike [cardholder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cardholder") + @ExcludeMissing + fun _cardholder(): JsonField = cardholder + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + /** + * Returns the raw JSON value of [pinEntered]. + * + * Unlike [pinEntered], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pin_entered") + @ExcludeMissing + fun _pinEntered(): JsonField = pinEntered + + @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 + * [AsaRequestPosEntryMode]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaRequestPosEntryMode]. */ + class Builder internal constructor() { + + private var card: JsonField = JsonMissing.of() + private var cardholder: JsonField = JsonMissing.of() + private var pan: JsonField = JsonMissing.of() + private var pinEntered: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaRequestPosEntryMode: AsaRequestPosEntryMode) = apply { + card = asaRequestPosEntryMode.card + cardholder = asaRequestPosEntryMode.cardholder + pan = asaRequestPosEntryMode.pan + pinEntered = asaRequestPosEntryMode.pinEntered + additionalProperties = + asaRequestPosEntryMode.additionalProperties.toMutableMap() + } + + /** Card Presence Indicator */ + fun card(card: Card) = card(JsonField.of(card)) + + /** + * Sets [Builder.card] to an arbitrary JSON value. + * + * You should usually call [Builder.card] with a well-typed [Card] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun card(card: JsonField) = apply { this.card = card } + + /** Cardholder Presence Indicator */ + fun cardholder(cardholder: Cardholder) = cardholder(JsonField.of(cardholder)) + + /** + * Sets [Builder.cardholder] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholder] with a well-typed [Cardholder] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cardholder(cardholder: JsonField) = apply { + this.cardholder = cardholder + } + + /** Method of entry for the PAN */ + fun pan(pan: Pan) = pan(JsonField.of(pan)) + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [Pan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pan(pan: JsonField) = apply { this.pan = pan } + + /** + * Indicates whether the cardholder entered the PIN. True if the PIN was entered. + */ + fun pinEntered(pinEntered: Boolean) = pinEntered(JsonField.of(pinEntered)) + + /** + * Sets [Builder.pinEntered] to an arbitrary JSON value. + * + * You should usually call [Builder.pinEntered] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pinEntered(pinEntered: JsonField) = apply { + this.pinEntered = pinEntered + } + + 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 [AsaRequestPosEntryMode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AsaRequestPosEntryMode = + AsaRequestPosEntryMode( + card, + cardholder, + pan, + pinEntered, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaRequestPosEntryMode = apply { + if (validated) { + return@apply + } + + card().ifPresent { it.validate() } + cardholder().ifPresent { it.validate() } + pan().ifPresent { it.validate() } + pinEntered() + 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 = + (card.asKnown().getOrNull()?.validity() ?: 0) + + (cardholder.asKnown().getOrNull()?.validity() ?: 0) + + (pan.asKnown().getOrNull()?.validity() ?: 0) + + (if (pinEntered.asKnown().isPresent) 1 else 0) + + /** Card Presence Indicator */ + class Card @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 PRESENT = of("PRESENT") + + @JvmField val NOT_PRESENT = of("NOT_PRESENT") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = Card(JsonField.of(value)) + } + + /** An enum containing [Card]'s known values. */ + enum class Known { + PRESENT, + NOT_PRESENT, + UNKNOWN, + } + + /** + * An enum containing [Card]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Card] 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 { + PRESENT, + NOT_PRESENT, + UNKNOWN, + /** + * An enum member indicating that [Card] 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) { + PRESENT -> Value.PRESENT + NOT_PRESENT -> Value.NOT_PRESENT + UNKNOWN -> Value.UNKNOWN + 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) { + PRESENT -> Known.PRESENT + NOT_PRESENT -> Known.NOT_PRESENT + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown Card: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Card = 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 Card && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cardholder Presence Indicator */ + class Cardholder + @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 DEFERRED_BILLING = of("DEFERRED_BILLING") + + @JvmField val ELECTRONIC_ORDER = of("ELECTRONIC_ORDER") + + @JvmField val INSTALLMENT = of("INSTALLMENT") + + @JvmField val MAIL_ORDER = of("MAIL_ORDER") + + @JvmField val NOT_PRESENT = of("NOT_PRESENT") + + @JvmField val PRESENT = of("PRESENT") + + @JvmField val REOCCURRING = of("REOCCURRING") + + @JvmField val TELEPHONE_ORDER = of("TELEPHONE_ORDER") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = Cardholder(JsonField.of(value)) + } + + /** An enum containing [Cardholder]'s known values. */ + enum class Known { + DEFERRED_BILLING, + ELECTRONIC_ORDER, + INSTALLMENT, + MAIL_ORDER, + NOT_PRESENT, + PRESENT, + REOCCURRING, + TELEPHONE_ORDER, + UNKNOWN, + } + + /** + * An enum containing [Cardholder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cardholder] 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 { + DEFERRED_BILLING, + ELECTRONIC_ORDER, + INSTALLMENT, + MAIL_ORDER, + NOT_PRESENT, + PRESENT, + REOCCURRING, + TELEPHONE_ORDER, + UNKNOWN, + /** + * An enum member indicating that [Cardholder] 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) { + DEFERRED_BILLING -> Value.DEFERRED_BILLING + ELECTRONIC_ORDER -> Value.ELECTRONIC_ORDER + INSTALLMENT -> Value.INSTALLMENT + MAIL_ORDER -> Value.MAIL_ORDER + NOT_PRESENT -> Value.NOT_PRESENT + PRESENT -> Value.PRESENT + REOCCURRING -> Value.REOCCURRING + TELEPHONE_ORDER -> Value.TELEPHONE_ORDER + UNKNOWN -> Value.UNKNOWN + 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) { + DEFERRED_BILLING -> Known.DEFERRED_BILLING + ELECTRONIC_ORDER -> Known.ELECTRONIC_ORDER + INSTALLMENT -> Known.INSTALLMENT + MAIL_ORDER -> Known.MAIL_ORDER + NOT_PRESENT -> Known.NOT_PRESENT + PRESENT -> Known.PRESENT + REOCCURRING -> Known.REOCCURRING + TELEPHONE_ORDER -> Known.TELEPHONE_ORDER + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown Cardholder: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cardholder = 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 Cardholder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Method of entry for the PAN */ + class Pan @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 AUTO_ENTRY = of("AUTO_ENTRY") + + @JvmField val BAR_CODE = of("BAR_CODE") + + @JvmField val CONTACTLESS = of("CONTACTLESS") + + @JvmField val ECOMMERCE = of("ECOMMERCE") + + @JvmField val ERROR_KEYED = of("ERROR_KEYED") + + @JvmField val ERROR_MAGNETIC_STRIPE = of("ERROR_MAGNETIC_STRIPE") + + @JvmField val ICC = of("ICC") + + @JvmField val KEY_ENTERED = of("KEY_ENTERED") + + @JvmField val MAGNETIC_STRIPE = of("MAGNETIC_STRIPE") + + @JvmField val MANUAL = of("MANUAL") + + @JvmField val OCR = of("OCR") + + @JvmField val SECURE_CARDLESS = of("SECURE_CARDLESS") + + @JvmField val UNSPECIFIED = of("UNSPECIFIED") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmField val CREDENTIAL_ON_FILE = of("CREDENTIAL_ON_FILE") + + @JvmStatic fun of(value: String) = Pan(JsonField.of(value)) + } + + /** An enum containing [Pan]'s known values. */ + enum class Known { + AUTO_ENTRY, + BAR_CODE, + CONTACTLESS, + ECOMMERCE, + ERROR_KEYED, + ERROR_MAGNETIC_STRIPE, + ICC, + KEY_ENTERED, + MAGNETIC_STRIPE, + MANUAL, + OCR, + SECURE_CARDLESS, + UNSPECIFIED, + UNKNOWN, + CREDENTIAL_ON_FILE, + } + + /** + * An enum containing [Pan]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Pan] 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 { + AUTO_ENTRY, + BAR_CODE, + CONTACTLESS, + ECOMMERCE, + ERROR_KEYED, + ERROR_MAGNETIC_STRIPE, + ICC, + KEY_ENTERED, + MAGNETIC_STRIPE, + MANUAL, + OCR, + SECURE_CARDLESS, + UNSPECIFIED, + UNKNOWN, + CREDENTIAL_ON_FILE, + /** + * An enum member indicating that [Pan] 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) { + AUTO_ENTRY -> Value.AUTO_ENTRY + BAR_CODE -> Value.BAR_CODE + CONTACTLESS -> Value.CONTACTLESS + ECOMMERCE -> Value.ECOMMERCE + ERROR_KEYED -> Value.ERROR_KEYED + ERROR_MAGNETIC_STRIPE -> Value.ERROR_MAGNETIC_STRIPE + ICC -> Value.ICC + KEY_ENTERED -> Value.KEY_ENTERED + MAGNETIC_STRIPE -> Value.MAGNETIC_STRIPE + MANUAL -> Value.MANUAL + OCR -> Value.OCR + SECURE_CARDLESS -> Value.SECURE_CARDLESS + UNSPECIFIED -> Value.UNSPECIFIED + UNKNOWN -> Value.UNKNOWN + CREDENTIAL_ON_FILE -> Value.CREDENTIAL_ON_FILE + 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) { + AUTO_ENTRY -> Known.AUTO_ENTRY + BAR_CODE -> Known.BAR_CODE + CONTACTLESS -> Known.CONTACTLESS + ECOMMERCE -> Known.ECOMMERCE + ERROR_KEYED -> Known.ERROR_KEYED + ERROR_MAGNETIC_STRIPE -> Known.ERROR_MAGNETIC_STRIPE + ICC -> Known.ICC + KEY_ENTERED -> Known.KEY_ENTERED + MAGNETIC_STRIPE -> Known.MAGNETIC_STRIPE + MANUAL -> Known.MANUAL + OCR -> Known.OCR + SECURE_CARDLESS -> Known.SECURE_CARDLESS + UNSPECIFIED -> Known.UNSPECIFIED + UNKNOWN -> Known.UNKNOWN + CREDENTIAL_ON_FILE -> Known.CREDENTIAL_ON_FILE + else -> throw LithicInvalidDataException("Unknown Pan: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Pan = 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 Pan && 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 AsaRequestPosEntryMode && + card == other.card && + cardholder == other.cardholder && + pan == other.pan && + pinEntered == other.pinEntered && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(card, cardholder, pan, pinEntered, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaRequestPosEntryMode{card=$card, cardholder=$cardholder, pan=$pan, pinEntered=$pinEntered, additionalProperties=$additionalProperties}" + } + + class AsaPosTerminal + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attended: JsonField, + private val cardRetentionCapable: JsonField, + private val onPremise: JsonField, + private val operator: JsonField, + private val partialApprovalCapable: JsonField, + private val pinCapability: JsonField, + private val type: JsonField, + private val acceptorTerminalId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attended") + @ExcludeMissing + attended: JsonField = JsonMissing.of(), + @JsonProperty("card_retention_capable") + @ExcludeMissing + cardRetentionCapable: JsonField = JsonMissing.of(), + @JsonProperty("on_premise") + @ExcludeMissing + onPremise: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("partial_approval_capable") + @ExcludeMissing + partialApprovalCapable: JsonField = JsonMissing.of(), + @JsonProperty("pin_capability") + @ExcludeMissing + pinCapability: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("acceptor_terminal_id") + @ExcludeMissing + acceptorTerminalId: JsonField = JsonMissing.of(), + ) : this( + attended, + cardRetentionCapable, + onPremise, + operator, + partialApprovalCapable, + pinCapability, + type, + acceptorTerminalId, + mutableMapOf(), + ) + + /** + * True if a clerk is present at the sale. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun attended(): Boolean = attended.getRequired("attended") + + /** + * True if the terminal is capable of retaining the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cardRetentionCapable(): Boolean = + cardRetentionCapable.getRequired("card_retention_capable") + + /** + * True if the sale was made at the place of business (vs. mobile). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun onPremise(): Boolean = onPremise.getRequired("on_premise") + + /** + * The person that is designated to swipe the card + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * True if the terminal is capable of partial approval. Partial approval is when part of + * a transaction is approved and another payment must be used for the remainder. Example + * scenario: A $40 transaction is attempted on a prepaid card with a $25 balance. If + * partial approval is enabled, $25 can be authorized, at which point the POS will + * prompt the user for an additional payment of $15. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun partialApprovalCapable(): Boolean = + partialApprovalCapable.getRequired("partial_approval_capable") + + /** + * Status of whether the POS is able to accept PINs + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pinCapability(): PinCapability = pinCapability.getRequired("pin_capability") + + /** + * POS 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 type(): Type = type.getRequired("type") + + /** + * Uniquely identifies a terminal at the card acceptor location of acquiring + * institutions or merchant POS Systems. Left justified with trailing spaces. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun acceptorTerminalId(): Optional = + acceptorTerminalId.getOptional("acceptor_terminal_id") + + /** + * Returns the raw JSON value of [attended]. + * + * Unlike [attended], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attended") @ExcludeMissing fun _attended(): JsonField = attended + + /** + * Returns the raw JSON value of [cardRetentionCapable]. + * + * Unlike [cardRetentionCapable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("card_retention_capable") + @ExcludeMissing + fun _cardRetentionCapable(): JsonField = cardRetentionCapable + + /** + * Returns the raw JSON value of [onPremise]. + * + * Unlike [onPremise], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_premise") + @ExcludeMissing + fun _onPremise(): JsonField = onPremise + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [partialApprovalCapable]. + * + * Unlike [partialApprovalCapable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("partial_approval_capable") + @ExcludeMissing + fun _partialApprovalCapable(): JsonField = partialApprovalCapable + + /** + * Returns the raw JSON value of [pinCapability]. + * + * Unlike [pinCapability], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pin_capability") + @ExcludeMissing + fun _pinCapability(): JsonField = pinCapability + + /** + * 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 [acceptorTerminalId]. + * + * Unlike [acceptorTerminalId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("acceptor_terminal_id") + @ExcludeMissing + fun _acceptorTerminalId(): JsonField = acceptorTerminalId + + @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 [AsaPosTerminal]. + * + * The following fields are required: + * ```java + * .attended() + * .cardRetentionCapable() + * .onPremise() + * .operator() + * .partialApprovalCapable() + * .pinCapability() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaPosTerminal]. */ + class Builder internal constructor() { + + private var attended: JsonField? = null + private var cardRetentionCapable: JsonField? = null + private var onPremise: JsonField? = null + private var operator: JsonField? = null + private var partialApprovalCapable: JsonField? = null + private var pinCapability: JsonField? = null + private var type: JsonField? = null + private var acceptorTerminalId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaPosTerminal: AsaPosTerminal) = apply { + attended = asaPosTerminal.attended + cardRetentionCapable = asaPosTerminal.cardRetentionCapable + onPremise = asaPosTerminal.onPremise + operator = asaPosTerminal.operator + partialApprovalCapable = asaPosTerminal.partialApprovalCapable + pinCapability = asaPosTerminal.pinCapability + type = asaPosTerminal.type + acceptorTerminalId = asaPosTerminal.acceptorTerminalId + additionalProperties = asaPosTerminal.additionalProperties.toMutableMap() + } + + /** True if a clerk is present at the sale. */ + fun attended(attended: Boolean) = attended(JsonField.of(attended)) + + /** + * Sets [Builder.attended] to an arbitrary JSON value. + * + * You should usually call [Builder.attended] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attended(attended: JsonField) = apply { this.attended = attended } + + /** True if the terminal is capable of retaining the card. */ + fun cardRetentionCapable(cardRetentionCapable: Boolean) = + cardRetentionCapable(JsonField.of(cardRetentionCapable)) + + /** + * Sets [Builder.cardRetentionCapable] to an arbitrary JSON value. + * + * You should usually call [Builder.cardRetentionCapable] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cardRetentionCapable(cardRetentionCapable: JsonField) = apply { + this.cardRetentionCapable = cardRetentionCapable + } + + /** True if the sale was made at the place of business (vs. mobile). */ + fun onPremise(onPremise: Boolean) = onPremise(JsonField.of(onPremise)) + + /** + * Sets [Builder.onPremise] to an arbitrary JSON value. + * + * You should usually call [Builder.onPremise] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun onPremise(onPremise: JsonField) = apply { this.onPremise = onPremise } + + /** The person that is designated to swipe the card */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** + * True if the terminal is capable of partial approval. Partial approval is when + * part of a transaction is approved and another payment must be used for the + * remainder. Example scenario: A $40 transaction is attempted on a prepaid card + * with a $25 balance. If partial approval is enabled, $25 can be authorized, at + * which point the POS will prompt the user for an additional payment of $15. + */ + fun partialApprovalCapable(partialApprovalCapable: Boolean) = + partialApprovalCapable(JsonField.of(partialApprovalCapable)) + + /** + * Sets [Builder.partialApprovalCapable] to an arbitrary JSON value. + * + * You should usually call [Builder.partialApprovalCapable] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun partialApprovalCapable(partialApprovalCapable: JsonField) = apply { + this.partialApprovalCapable = partialApprovalCapable + } + + /** Status of whether the POS is able to accept PINs */ + fun pinCapability(pinCapability: PinCapability) = + pinCapability(JsonField.of(pinCapability)) + + /** + * Sets [Builder.pinCapability] to an arbitrary JSON value. + * + * You should usually call [Builder.pinCapability] with a well-typed [PinCapability] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun pinCapability(pinCapability: JsonField) = apply { + this.pinCapability = pinCapability + } + + /** POS 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 [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 } + + /** + * Uniquely identifies a terminal at the card acceptor location of acquiring + * institutions or merchant POS Systems. Left justified with trailing spaces. + */ + fun acceptorTerminalId(acceptorTerminalId: String?) = + acceptorTerminalId(JsonField.ofNullable(acceptorTerminalId)) + + /** + * Alias for calling [Builder.acceptorTerminalId] with + * `acceptorTerminalId.orElse(null)`. + */ + fun acceptorTerminalId(acceptorTerminalId: Optional) = + acceptorTerminalId(acceptorTerminalId.getOrNull()) + + /** + * Sets [Builder.acceptorTerminalId] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptorTerminalId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun acceptorTerminalId(acceptorTerminalId: JsonField) = apply { + this.acceptorTerminalId = acceptorTerminalId + } + + 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 [AsaPosTerminal]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attended() + * .cardRetentionCapable() + * .onPremise() + * .operator() + * .partialApprovalCapable() + * .pinCapability() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AsaPosTerminal = + AsaPosTerminal( + checkRequired("attended", attended), + checkRequired("cardRetentionCapable", cardRetentionCapable), + checkRequired("onPremise", onPremise), + checkRequired("operator", operator), + checkRequired("partialApprovalCapable", partialApprovalCapable), + checkRequired("pinCapability", pinCapability), + checkRequired("type", type), + acceptorTerminalId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AsaPosTerminal = apply { + if (validated) { + return@apply + } + + attended() + cardRetentionCapable() + onPremise() + operator().validate() + partialApprovalCapable() + pinCapability().validate() + type().validate() + acceptorTerminalId() + 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 (attended.asKnown().isPresent) 1 else 0) + + (if (cardRetentionCapable.asKnown().isPresent) 1 else 0) + + (if (onPremise.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (if (partialApprovalCapable.asKnown().isPresent) 1 else 0) + + (pinCapability.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (acceptorTerminalId.asKnown().isPresent) 1 else 0) + + /** The person that is designated to swipe the card */ + class Operator @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 ADMINISTRATIVE = of("ADMINISTRATIVE") + + @JvmField val CARDHOLDER = of("CARDHOLDER") + + @JvmField val CARD_ACCEPTOR = of("CARD_ACCEPTOR") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + ADMINISTRATIVE, + CARDHOLDER, + CARD_ACCEPTOR, + UNKNOWN, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] 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 { + ADMINISTRATIVE, + CARDHOLDER, + CARD_ACCEPTOR, + UNKNOWN, + /** + * An enum member indicating that [Operator] 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) { + ADMINISTRATIVE -> Value.ADMINISTRATIVE + CARDHOLDER -> Value.CARDHOLDER + CARD_ACCEPTOR -> Value.CARD_ACCEPTOR + UNKNOWN -> Value.UNKNOWN + 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) { + ADMINISTRATIVE -> Known.ADMINISTRATIVE + CARDHOLDER -> Known.CARDHOLDER + CARD_ACCEPTOR -> Known.CARD_ACCEPTOR + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown Operator: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = 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 Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Status of whether the POS is able to accept PINs */ + class PinCapability + @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 CAPABLE = of("CAPABLE") + + @JvmField val INOPERATIVE = of("INOPERATIVE") + + @JvmField val NOT_CAPABLE = of("NOT_CAPABLE") + + @JvmField val UNSPECIFIED = of("UNSPECIFIED") + + @JvmStatic fun of(value: String) = PinCapability(JsonField.of(value)) + } + + /** An enum containing [PinCapability]'s known values. */ + enum class Known { + CAPABLE, + INOPERATIVE, + NOT_CAPABLE, + UNSPECIFIED, + } + + /** + * An enum containing [PinCapability]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [PinCapability] 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 { + CAPABLE, + INOPERATIVE, + NOT_CAPABLE, + UNSPECIFIED, + /** + * An enum member indicating that [PinCapability] 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) { + CAPABLE -> Value.CAPABLE + INOPERATIVE -> Value.INOPERATIVE + NOT_CAPABLE -> Value.NOT_CAPABLE + UNSPECIFIED -> Value.UNSPECIFIED + 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) { + CAPABLE -> Known.CAPABLE + INOPERATIVE -> Known.INOPERATIVE + NOT_CAPABLE -> Known.NOT_CAPABLE + UNSPECIFIED -> Known.UNSPECIFIED + else -> throw LithicInvalidDataException("Unknown PinCapability: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): PinCapability = 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 PinCapability && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** POS Type */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ADMINISTRATIVE = of("ADMINISTRATIVE") + + @JvmField val ATM = of("ATM") + + @JvmField val AUTHORIZATION = of("AUTHORIZATION") + + @JvmField val COUPON_MACHINE = of("COUPON_MACHINE") + + @JvmField val DIAL_TERMINAL = of("DIAL_TERMINAL") + + @JvmField val ECOMMERCE = of("ECOMMERCE") + + @JvmField val ECR = of("ECR") + + @JvmField val FUEL_MACHINE = of("FUEL_MACHINE") + + @JvmField val HOME_TERMINAL = of("HOME_TERMINAL") + + @JvmField val MICR = of("MICR") + + @JvmField val OFF_PREMISE = of("OFF_PREMISE") + + @JvmField val PAYMENT = of("PAYMENT") + + @JvmField val PDA = of("PDA") + + @JvmField val PHONE = of("PHONE") + + @JvmField val POINT = of("POINT") + + @JvmField val POS_TERMINAL = of("POS_TERMINAL") + + @JvmField val PUBLIC_UTILITY = of("PUBLIC_UTILITY") + + @JvmField val SELF_SERVICE = of("SELF_SERVICE") + + @JvmField val TELEVISION = of("TELEVISION") + + @JvmField val TELLER = of("TELLER") + + @JvmField val TRAVELERS_CHECK_MACHINE = of("TRAVELERS_CHECK_MACHINE") + + @JvmField val VENDING = of("VENDING") + + @JvmField val VOICE = of("VOICE") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ADMINISTRATIVE, + ATM, + AUTHORIZATION, + COUPON_MACHINE, + DIAL_TERMINAL, + ECOMMERCE, + ECR, + FUEL_MACHINE, + HOME_TERMINAL, + MICR, + OFF_PREMISE, + PAYMENT, + PDA, + PHONE, + POINT, + POS_TERMINAL, + PUBLIC_UTILITY, + SELF_SERVICE, + TELEVISION, + TELLER, + TRAVELERS_CHECK_MACHINE, + VENDING, + VOICE, + UNKNOWN, + } + + /** + * 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 { + ADMINISTRATIVE, + ATM, + AUTHORIZATION, + COUPON_MACHINE, + DIAL_TERMINAL, + ECOMMERCE, + ECR, + FUEL_MACHINE, + HOME_TERMINAL, + MICR, + OFF_PREMISE, + PAYMENT, + PDA, + PHONE, + POINT, + POS_TERMINAL, + PUBLIC_UTILITY, + SELF_SERVICE, + TELEVISION, + TELLER, + TRAVELERS_CHECK_MACHINE, + VENDING, + VOICE, + UNKNOWN, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ADMINISTRATIVE -> Value.ADMINISTRATIVE + ATM -> Value.ATM + AUTHORIZATION -> Value.AUTHORIZATION + COUPON_MACHINE -> Value.COUPON_MACHINE + DIAL_TERMINAL -> Value.DIAL_TERMINAL + ECOMMERCE -> Value.ECOMMERCE + ECR -> Value.ECR + FUEL_MACHINE -> Value.FUEL_MACHINE + HOME_TERMINAL -> Value.HOME_TERMINAL + MICR -> Value.MICR + OFF_PREMISE -> Value.OFF_PREMISE + PAYMENT -> Value.PAYMENT + PDA -> Value.PDA + PHONE -> Value.PHONE + POINT -> Value.POINT + POS_TERMINAL -> Value.POS_TERMINAL + PUBLIC_UTILITY -> Value.PUBLIC_UTILITY + SELF_SERVICE -> Value.SELF_SERVICE + TELEVISION -> Value.TELEVISION + TELLER -> Value.TELLER + TRAVELERS_CHECK_MACHINE -> Value.TRAVELERS_CHECK_MACHINE + VENDING -> Value.VENDING + VOICE -> Value.VOICE + UNKNOWN -> Value.UNKNOWN + 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) { + ADMINISTRATIVE -> Known.ADMINISTRATIVE + ATM -> Known.ATM + AUTHORIZATION -> Known.AUTHORIZATION + COUPON_MACHINE -> Known.COUPON_MACHINE + DIAL_TERMINAL -> Known.DIAL_TERMINAL + ECOMMERCE -> Known.ECOMMERCE + ECR -> Known.ECR + FUEL_MACHINE -> Known.FUEL_MACHINE + HOME_TERMINAL -> Known.HOME_TERMINAL + MICR -> Known.MICR + OFF_PREMISE -> Known.OFF_PREMISE + PAYMENT -> Known.PAYMENT + PDA -> Known.PDA + PHONE -> Known.PHONE + POINT -> Known.POINT + POS_TERMINAL -> Known.POS_TERMINAL + PUBLIC_UTILITY -> Known.PUBLIC_UTILITY + SELF_SERVICE -> Known.SELF_SERVICE + TELEVISION -> Known.TELEVISION + TELLER -> Known.TELLER + TRAVELERS_CHECK_MACHINE -> Known.TRAVELERS_CHECK_MACHINE + VENDING -> Known.VENDING + VOICE -> Known.VOICE + UNKNOWN -> Known.UNKNOWN + 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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + 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 + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AsaPosTerminal && + attended == other.attended && + cardRetentionCapable == other.cardRetentionCapable && + onPremise == other.onPremise && + operator == other.operator && + partialApprovalCapable == other.partialApprovalCapable && + pinCapability == other.pinCapability && + type == other.type && + acceptorTerminalId == other.acceptorTerminalId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attended, + cardRetentionCapable, + onPremise, + operator, + partialApprovalCapable, + pinCapability, + type, + acceptorTerminalId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaPosTerminal{attended=$attended, cardRetentionCapable=$cardRetentionCapable, onPremise=$onPremise, operator=$operator, partialApprovalCapable=$partialApprovalCapable, pinCapability=$pinCapability, type=$type, acceptorTerminalId=$acceptorTerminalId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Pos && + entryMode == other.entryMode && + terminal == other.terminal && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(entryMode, terminal, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Pos{entryMode=$entryMode, terminal=$terminal, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardAuthorization && + token == other.token && + acquirerFee == other.acquirerFee && + amount == other.amount && + amounts == other.amounts && + authorizationAmount == other.authorizationAmount && + avs == other.avs && + card == other.card && + cardholderCurrency == other.cardholderCurrency && + cashAmount == other.cashAmount && + created == other.created && + merchant == other.merchant && + merchantAmount == other.merchantAmount && + merchantCurrency == other.merchantCurrency && + serviceLocation == other.serviceLocation && + settledAmount == other.settledAmount && + status == other.status && + transactionInitiator == other.transactionInitiator && + accountType == other.accountType && + cardholderAuthentication == other.cardholderAuthentication && + cashback == other.cashback && + conversionRate == other.conversionRate && + eventToken == other.eventToken && + fleetInfo == other.fleetInfo && + latestChallenge == other.latestChallenge && + network == other.network && + networkRiskScore == other.networkRiskScore && + networkSpecificData == other.networkSpecificData && + pos == other.pos && + tokenInfo == other.tokenInfo && + ttl == other.ttl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + acquirerFee, + amount, + amounts, + authorizationAmount, + avs, + card, + cardholderCurrency, + cashAmount, + created, + merchant, + merchantAmount, + merchantCurrency, + serviceLocation, + settledAmount, + status, + transactionInitiator, + accountType, + cardholderAuthentication, + cashback, + conversionRate, + eventToken, + fleetInfo, + latestChallenge, + network, + networkRiskScore, + networkSpecificData, + pos, + tokenInfo, + ttl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardAuthorization{token=$token, acquirerFee=$acquirerFee, amount=$amount, amounts=$amounts, authorizationAmount=$authorizationAmount, avs=$avs, card=$card, cardholderCurrency=$cardholderCurrency, cashAmount=$cashAmount, created=$created, merchant=$merchant, merchantAmount=$merchantAmount, merchantCurrency=$merchantCurrency, serviceLocation=$serviceLocation, settledAmount=$settledAmount, status=$status, transactionInitiator=$transactionInitiator, accountType=$accountType, cardholderAuthentication=$cardholderAuthentication, cashback=$cashback, conversionRate=$conversionRate, eventToken=$eventToken, fleetInfo=$fleetInfo, latestChallenge=$latestChallenge, network=$network, networkRiskScore=$networkRiskScore, networkSpecificData=$networkSpecificData, pos=$pos, tokenInfo=$tokenInfo, ttl=$ttl, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEvent.kt index 09a7f204..a43d7f34 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEvent.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEvent.kt @@ -11,9 +11,7 @@ import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue -import com.lithic.api.core.checkKnown import com.lithic.api.core.checkRequired -import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -21,40 +19,41 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** The Auth Stream Access request payload that was sent to the ASA responder. */ class CardAuthorizationApprovalRequestWebhookEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, private val acquirerFee: JsonField, private val amount: JsonField, - private val amounts: JsonField, + private val amounts: JsonField, private val authorizationAmount: JsonField, - private val avs: JsonField, - private val card: JsonField, + private val avs: JsonField, + private val card: JsonField, private val cardholderCurrency: JsonField, private val cashAmount: JsonField, private val created: JsonField, - private val eventType: JsonField, - private val merchant: JsonField, + private val merchant: JsonField, private val merchantAmount: JsonField, private val merchantCurrency: JsonField, - private val serviceLocation: JsonField, + private val serviceLocation: JsonField, private val settledAmount: JsonField, - private val status: JsonField, - private val transactionInitiator: JsonField, - private val accountType: JsonField, + private val status: JsonField, + private val transactionInitiator: JsonField, + private val accountType: JsonField, private val cardholderAuthentication: JsonField, private val cashback: JsonField, private val conversionRate: JsonField, private val eventToken: JsonField, - private val fleetInfo: JsonField, - private val latestChallenge: JsonField, - private val network: JsonField, + private val fleetInfo: JsonField, + private val latestChallenge: JsonField, + private val network: JsonField, private val networkRiskScore: JsonField, - private val networkSpecificData: JsonField, - private val pos: JsonField, + private val networkSpecificData: JsonField, + private val pos: JsonField, private val tokenInfo: JsonField, private val ttl: JsonField, + private val eventType: JsonField, private val additionalProperties: MutableMap, ) { @@ -65,12 +64,18 @@ private constructor( @ExcludeMissing acquirerFee: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("amounts") @ExcludeMissing amounts: JsonField = JsonMissing.of(), + @JsonProperty("amounts") + @ExcludeMissing + amounts: JsonField = JsonMissing.of(), @JsonProperty("authorization_amount") @ExcludeMissing authorizationAmount: JsonField = JsonMissing.of(), - @JsonProperty("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), - @JsonProperty("card") @ExcludeMissing card: JsonField = JsonMissing.of(), + @JsonProperty("avs") + @ExcludeMissing + avs: JsonField = JsonMissing.of(), + @JsonProperty("card") + @ExcludeMissing + card: JsonField = JsonMissing.of(), @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), @@ -78,12 +83,9 @@ private constructor( @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), - @JsonProperty("event_type") - @ExcludeMissing - eventType: JsonField = JsonMissing.of(), @JsonProperty("merchant") @ExcludeMissing - merchant: JsonField = JsonMissing.of(), + merchant: JsonField = JsonMissing.of(), @JsonProperty("merchant_amount") @ExcludeMissing merchantAmount: JsonField = JsonMissing.of(), @@ -92,19 +94,19 @@ private constructor( merchantCurrency: JsonField = JsonMissing.of(), @JsonProperty("service_location") @ExcludeMissing - serviceLocation: JsonField = JsonMissing.of(), + serviceLocation: JsonField = JsonMissing.of(), @JsonProperty("settled_amount") @ExcludeMissing settledAmount: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing - status: JsonField = JsonMissing.of(), + status: JsonField = JsonMissing.of(), @JsonProperty("transaction_initiator") @ExcludeMissing - transactionInitiator: JsonField = JsonMissing.of(), + transactionInitiator: JsonField = JsonMissing.of(), @JsonProperty("account_type") @ExcludeMissing - accountType: JsonField = JsonMissing.of(), + accountType: JsonField = JsonMissing.of(), @JsonProperty("cardholder_authentication") @ExcludeMissing cardholderAuthentication: JsonField = JsonMissing.of(), @@ -117,22 +119,29 @@ private constructor( eventToken: JsonField = JsonMissing.of(), @JsonProperty("fleet_info") @ExcludeMissing - fleetInfo: JsonField = JsonMissing.of(), + fleetInfo: JsonField = JsonMissing.of(), @JsonProperty("latest_challenge") @ExcludeMissing - latestChallenge: JsonField = JsonMissing.of(), - @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + latestChallenge: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), @JsonProperty("network_risk_score") @ExcludeMissing networkRiskScore: JsonField = JsonMissing.of(), @JsonProperty("network_specific_data") @ExcludeMissing - networkSpecificData: JsonField = JsonMissing.of(), - @JsonProperty("pos") @ExcludeMissing pos: JsonField = JsonMissing.of(), + networkSpecificData: JsonField = JsonMissing.of(), + @JsonProperty("pos") + @ExcludeMissing + pos: JsonField = JsonMissing.of(), @JsonProperty("token_info") @ExcludeMissing tokenInfo: JsonField = JsonMissing.of(), @JsonProperty("ttl") @ExcludeMissing ttl: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), ) : this( token, acquirerFee, @@ -144,7 +153,6 @@ private constructor( cardholderCurrency, cashAmount, created, - eventType, merchant, merchantAmount, merchantCurrency, @@ -165,9 +173,44 @@ private constructor( pos, tokenInfo, ttl, + eventType, mutableMapOf(), ) + fun toCardAuthorization(): CardAuthorization = + CardAuthorization.builder() + .token(token) + .acquirerFee(acquirerFee) + .amount(amount) + .amounts(amounts) + .authorizationAmount(authorizationAmount) + .avs(avs) + .card(card) + .cardholderCurrency(cardholderCurrency) + .cashAmount(cashAmount) + .created(created) + .merchant(merchant) + .merchantAmount(merchantAmount) + .merchantCurrency(merchantCurrency) + .serviceLocation(serviceLocation) + .settledAmount(settledAmount) + .status(status) + .transactionInitiator(transactionInitiator) + .accountType(accountType) + .cardholderAuthentication(cardholderAuthentication) + .cashback(cashback) + .conversionRate(conversionRate) + .eventToken(eventToken) + .fleetInfo(fleetInfo) + .latestChallenge(latestChallenge) + .network(network) + .networkRiskScore(networkRiskScore) + .networkSpecificData(networkSpecificData) + .pos(pos) + .tokenInfo(tokenInfo) + .ttl(ttl) + .build() + /** * The provisional transaction group uuid associated with the authorization * @@ -204,7 +247,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 amounts(): Amounts = amounts.getRequired("amounts") + fun amounts(): CardAuthorization.Amounts = amounts.getRequired("amounts") /** * Deprecated, use `amounts`. The base transaction amount (in cents) plus the acquirer fee @@ -221,7 +264,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 avs(): Avs = avs.getRequired("avs") + fun avs(): CardAuthorization.Avs = avs.getRequired("avs") /** * Card object in ASA @@ -229,7 +272,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 card(): AsaRequestCard = card.getRequired("card") + fun card(): CardAuthorization.AsaRequestCard = card.getRequired("card") /** * Deprecated, use `amounts`. 3-character alphabetic ISO 4217 code for cardholder's billing @@ -262,19 +305,13 @@ private constructor( */ 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 eventType(): EventType = eventType.getRequired("event_type") - /** * Merchant information including full location details. * * @throws LithicInvalidDataException if 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(): TransactionMerchant = merchant.getRequired("merchant") + fun merchant(): CardAuthorization.TransactionMerchant = merchant.getRequired("merchant") /** * Deprecated, use `amounts`. The amount that the merchant will receive, denominated in @@ -305,7 +342,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun serviceLocation(): Optional = + fun serviceLocation(): Optional = serviceLocation.getOptional("service_location") /** @@ -326,7 +363,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 status(): AsaRequestStatus = status.getRequired("status") + fun status(): CardAuthorization.AsaRequestStatus = status.getRequired("status") /** * The entity that initiated the transaction. @@ -334,14 +371,15 @@ 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 transactionInitiator(): TransactionInitiator = + fun transactionInitiator(): CardAuthorization.TransactionInitiator = transactionInitiator.getRequired("transaction_initiator") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun accountType(): Optional = accountType.getOptional("account_type") + fun accountType(): Optional = + accountType.getOptional("account_type") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -386,7 +424,8 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun fleetInfo(): Optional = fleetInfo.getOptional("fleet_info") + fun fleetInfo(): Optional = + fleetInfo.getOptional("fleet_info") /** * The latest Authorization Challenge that was issued to the cardholder for this merchant. @@ -394,7 +433,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun latestChallenge(): Optional = + fun latestChallenge(): Optional = latestChallenge.getOptional("latest_challenge") /** @@ -403,7 +442,7 @@ private constructor( * @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") + fun network(): Optional = network.getOptional("network") /** * Network-provided score assessing risk level associated with a given authorization. Scores are @@ -427,14 +466,14 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun networkSpecificData(): Optional = + fun networkSpecificData(): Optional = networkSpecificData.getOptional("network_specific_data") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun pos(): Optional = pos.getOptional("pos") + fun pos(): Optional = pos.getOptional("pos") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -450,6 +489,12 @@ private constructor( */ fun ttl(): Optional = ttl.getOptional("ttl") + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventType(): EventType = eventType.getRequired("event_type") + /** * Returns the raw JSON value of [token]. * @@ -479,7 +524,9 @@ private constructor( * * Unlike [amounts], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("amounts") @ExcludeMissing fun _amounts(): JsonField = amounts + @JsonProperty("amounts") + @ExcludeMissing + fun _amounts(): JsonField = amounts /** * Returns the raw JSON value of [authorizationAmount]. @@ -497,14 +544,16 @@ private constructor( * * Unlike [avs], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("avs") @ExcludeMissing fun _avs(): JsonField = avs + @JsonProperty("avs") @ExcludeMissing fun _avs(): JsonField = avs /** * Returns the raw JSON value of [card]. * * Unlike [card], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("card") @ExcludeMissing fun _card(): JsonField = card + @JsonProperty("card") + @ExcludeMissing + fun _card(): JsonField = card /** * Returns the raw JSON value of [cardholderCurrency]. @@ -531,13 +580,6 @@ private constructor( */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** - * Returns the raw JSON value of [eventType]. - * - * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType - /** * Returns the raw JSON value of [merchant]. * @@ -545,7 +587,7 @@ private constructor( */ @JsonProperty("merchant") @ExcludeMissing - fun _merchant(): JsonField = merchant + fun _merchant(): JsonField = merchant /** * Returns the raw JSON value of [merchantAmount]. @@ -575,7 +617,7 @@ private constructor( */ @JsonProperty("service_location") @ExcludeMissing - fun _serviceLocation(): JsonField = serviceLocation + fun _serviceLocation(): JsonField = serviceLocation /** * Returns the raw JSON value of [settledAmount]. @@ -592,7 +634,9 @@ private constructor( * * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status /** * Returns the raw JSON value of [transactionInitiator]. @@ -602,7 +646,8 @@ private constructor( */ @JsonProperty("transaction_initiator") @ExcludeMissing - fun _transactionInitiator(): JsonField = transactionInitiator + fun _transactionInitiator(): JsonField = + transactionInitiator /** * Returns the raw JSON value of [accountType]. @@ -611,7 +656,7 @@ private constructor( */ @JsonProperty("account_type") @ExcludeMissing - fun _accountType(): JsonField = accountType + fun _accountType(): JsonField = accountType /** * Returns the raw JSON value of [cardholderAuthentication]. @@ -654,7 +699,7 @@ private constructor( */ @JsonProperty("fleet_info") @ExcludeMissing - fun _fleetInfo(): JsonField = fleetInfo + fun _fleetInfo(): JsonField = fleetInfo /** * Returns the raw JSON value of [latestChallenge]. @@ -663,14 +708,16 @@ private constructor( */ @JsonProperty("latest_challenge") @ExcludeMissing - fun _latestChallenge(): JsonField = latestChallenge + fun _latestChallenge(): JsonField = latestChallenge /** * 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 + @JsonProperty("network") + @ExcludeMissing + fun _network(): JsonField = network /** * Returns the raw JSON value of [networkRiskScore]. @@ -690,14 +737,15 @@ private constructor( */ @JsonProperty("network_specific_data") @ExcludeMissing - fun _networkSpecificData(): JsonField = networkSpecificData + fun _networkSpecificData(): JsonField = + networkSpecificData /** * 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 + @JsonProperty("pos") @ExcludeMissing fun _pos(): JsonField = pos /** * Returns the raw JSON value of [tokenInfo]. @@ -713,6 +761,13 @@ private constructor( */ @JsonProperty("ttl") @ExcludeMissing fun _ttl(): JsonField = ttl + /** + * Returns the raw JSON value of [eventType]. + * + * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -743,7 +798,6 @@ private constructor( * .cardholderCurrency() * .cashAmount() * .created() - * .eventType() * .merchant() * .merchantAmount() * .merchantCurrency() @@ -751,6 +805,7 @@ private constructor( * .settledAmount() * .status() * .transactionInitiator() + * .eventType() * ``` */ @JvmStatic fun builder() = Builder() @@ -762,34 +817,35 @@ private constructor( private var token: JsonField? = null private var acquirerFee: JsonField? = null private var amount: JsonField? = null - private var amounts: JsonField? = null + private var amounts: JsonField? = null private var authorizationAmount: JsonField? = null - private var avs: JsonField? = null - private var card: JsonField? = null + private var avs: JsonField? = null + private var card: JsonField? = null private var cardholderCurrency: JsonField? = null private var cashAmount: JsonField? = null private var created: JsonField? = null - private var eventType: JsonField? = null - private var merchant: JsonField? = null + private var merchant: JsonField? = null private var merchantAmount: JsonField? = null private var merchantCurrency: JsonField? = null - private var serviceLocation: JsonField? = null + private var serviceLocation: JsonField? = null private var settledAmount: JsonField? = null - private var status: JsonField? = null - private var transactionInitiator: JsonField? = null - private var accountType: JsonField = JsonMissing.of() + private var status: JsonField? = null + private var transactionInitiator: JsonField? = null + private var accountType: JsonField = JsonMissing.of() private var cardholderAuthentication: JsonField = JsonMissing.of() private var cashback: JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var eventToken: JsonField = JsonMissing.of() - private var fleetInfo: JsonField = JsonMissing.of() - private var latestChallenge: JsonField = JsonMissing.of() - private var network: JsonField = JsonMissing.of() + private var fleetInfo: JsonField = JsonMissing.of() + private var latestChallenge: JsonField = JsonMissing.of() + private var network: JsonField = JsonMissing.of() private var networkRiskScore: JsonField = JsonMissing.of() - private var networkSpecificData: JsonField = JsonMissing.of() - private var pos: JsonField = JsonMissing.of() + private var networkSpecificData: JsonField = + JsonMissing.of() + private var pos: JsonField = JsonMissing.of() private var tokenInfo: JsonField = JsonMissing.of() private var ttl: JsonField = JsonMissing.of() + private var eventType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -807,7 +863,6 @@ private constructor( cardholderCurrency = cardAuthorizationApprovalRequestWebhookEvent.cardholderCurrency cashAmount = cardAuthorizationApprovalRequestWebhookEvent.cashAmount created = cardAuthorizationApprovalRequestWebhookEvent.created - eventType = cardAuthorizationApprovalRequestWebhookEvent.eventType merchant = cardAuthorizationApprovalRequestWebhookEvent.merchant merchantAmount = cardAuthorizationApprovalRequestWebhookEvent.merchantAmount merchantCurrency = cardAuthorizationApprovalRequestWebhookEvent.merchantCurrency @@ -829,6 +884,7 @@ private constructor( pos = cardAuthorizationApprovalRequestWebhookEvent.pos tokenInfo = cardAuthorizationApprovalRequestWebhookEvent.tokenInfo ttl = cardAuthorizationApprovalRequestWebhookEvent.ttl + eventType = cardAuthorizationApprovalRequestWebhookEvent.eventType additionalProperties = cardAuthorizationApprovalRequestWebhookEvent.additionalProperties.toMutableMap() } @@ -882,15 +938,18 @@ private constructor( * the `cardholder` and `merchant` amounts to account for anticipated final transaction * amounts such as tips or fuel fill-ups */ - fun amounts(amounts: Amounts) = amounts(JsonField.of(amounts)) + fun amounts(amounts: CardAuthorization.Amounts) = amounts(JsonField.of(amounts)) /** * Sets [Builder.amounts] to an arbitrary JSON value. * - * You should usually call [Builder.amounts] with a well-typed [Amounts] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.amounts] with a well-typed [CardAuthorization.Amounts] + * 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 } + fun amounts(amounts: JsonField) = apply { + this.amounts = amounts + } /** * Deprecated, use `amounts`. The base transaction amount (in cents) plus the acquirer fee @@ -913,27 +972,28 @@ private constructor( this.authorizationAmount = authorizationAmount } - fun avs(avs: Avs) = avs(JsonField.of(avs)) + fun avs(avs: CardAuthorization.Avs) = avs(JsonField.of(avs)) /** * Sets [Builder.avs] to an arbitrary JSON value. * - * You should usually call [Builder.avs] with a well-typed [Avs] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.avs] with a well-typed [CardAuthorization.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 } + fun avs(avs: JsonField) = apply { this.avs = avs } /** Card object in ASA */ - fun card(card: AsaRequestCard) = card(JsonField.of(card)) + fun card(card: CardAuthorization.AsaRequestCard) = card(JsonField.of(card)) /** * Sets [Builder.card] to an arbitrary JSON value. * - * You should usually call [Builder.card] with a well-typed [AsaRequestCard] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.card] with a well-typed + * [CardAuthorization.AsaRequestCard] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun card(card: JsonField) = apply { this.card = card } + fun card(card: JsonField) = apply { this.card = card } /** * Deprecated, use `amounts`. 3-character alphabetic ISO 4217 code for cardholder's billing @@ -985,28 +1045,20 @@ private constructor( */ fun created(created: JsonField) = apply { this.created = created } - fun eventType(eventType: EventType) = eventType(JsonField.of(eventType)) - - /** - * Sets [Builder.eventType] to an arbitrary JSON value. - * - * You should usually call [Builder.eventType] with a well-typed [EventType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun eventType(eventType: JsonField) = apply { this.eventType = eventType } - /** Merchant information including full location details. */ - fun merchant(merchant: TransactionMerchant) = merchant(JsonField.of(merchant)) + fun merchant(merchant: CardAuthorization.TransactionMerchant) = + merchant(JsonField.of(merchant)) /** * Sets [Builder.merchant] to an arbitrary JSON value. * - * You should usually call [Builder.merchant] with a well-typed [TransactionMerchant] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.merchant] with a well-typed + * [CardAuthorization.TransactionMerchant] 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 } + fun merchant(merchant: JsonField) = apply { + this.merchant = merchant + } /** * Deprecated, use `amounts`. The amount that the merchant will receive, denominated in @@ -1051,21 +1103,21 @@ private constructor( * location. This is populated from network data elements such as Mastercard DE-122 SE1 * SF9-14 and Visa F34 DS02. */ - fun serviceLocation(serviceLocation: ServiceLocation?) = + fun serviceLocation(serviceLocation: CardAuthorization.ServiceLocation?) = serviceLocation(JsonField.ofNullable(serviceLocation)) /** Alias for calling [Builder.serviceLocation] with `serviceLocation.orElse(null)`. */ - fun serviceLocation(serviceLocation: Optional) = + fun serviceLocation(serviceLocation: Optional) = serviceLocation(serviceLocation.getOrNull()) /** * Sets [Builder.serviceLocation] to an arbitrary JSON value. * - * You should usually call [Builder.serviceLocation] with a well-typed [ServiceLocation] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.serviceLocation] with a well-typed + * [CardAuthorization.ServiceLocation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun serviceLocation(serviceLocation: JsonField) = apply { + fun serviceLocation(serviceLocation: JsonField) = apply { this.serviceLocation = serviceLocation } @@ -1093,42 +1145,45 @@ private constructor( * `CREDIT_AUTHORIZATION` and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to users * with credit decisioning via ASA enabled. */ - fun status(status: AsaRequestStatus) = status(JsonField.of(status)) + fun status(status: CardAuthorization.AsaRequestStatus) = status(JsonField.of(status)) /** * Sets [Builder.status] to an arbitrary JSON value. * - * You should usually call [Builder.status] with a well-typed [AsaRequestStatus] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.status] with a well-typed + * [CardAuthorization.AsaRequestStatus] 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 status(status: JsonField) = apply { + this.status = status + } /** The entity that initiated the transaction. */ - fun transactionInitiator(transactionInitiator: TransactionInitiator) = + fun transactionInitiator(transactionInitiator: CardAuthorization.TransactionInitiator) = transactionInitiator(JsonField.of(transactionInitiator)) /** * Sets [Builder.transactionInitiator] to an arbitrary JSON value. * * You should usually call [Builder.transactionInitiator] with a well-typed - * [TransactionInitiator] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * [CardAuthorization.TransactionInitiator] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun transactionInitiator(transactionInitiator: JsonField) = apply { - this.transactionInitiator = transactionInitiator - } + fun transactionInitiator( + transactionInitiator: JsonField + ) = apply { this.transactionInitiator = transactionInitiator } - fun accountType(accountType: AccountType) = accountType(JsonField.of(accountType)) + fun accountType(accountType: CardAuthorization.AccountType) = + accountType(JsonField.of(accountType)) /** * Sets [Builder.accountType] to an arbitrary JSON value. * - * You should usually call [Builder.accountType] with a well-typed [AccountType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.accountType] with a well-typed + * [CardAuthorization.AccountType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun accountType(accountType: JsonField) = apply { + fun accountType(accountType: JsonField) = apply { this.accountType = accountType } @@ -1197,49 +1252,54 @@ private constructor( /** * Optional Object containing information if the Card is a part of a Fleet managed program */ - fun fleetInfo(fleetInfo: AsaRequestFleetInfo?) = fleetInfo(JsonField.ofNullable(fleetInfo)) + fun fleetInfo(fleetInfo: CardAuthorization.AsaRequestFleetInfo?) = + fleetInfo(JsonField.ofNullable(fleetInfo)) /** Alias for calling [Builder.fleetInfo] with `fleetInfo.orElse(null)`. */ - fun fleetInfo(fleetInfo: Optional) = fleetInfo(fleetInfo.getOrNull()) + fun fleetInfo(fleetInfo: Optional) = + fleetInfo(fleetInfo.getOrNull()) /** * Sets [Builder.fleetInfo] to an arbitrary JSON value. * - * You should usually call [Builder.fleetInfo] with a well-typed [AsaRequestFleetInfo] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.fleetInfo] with a well-typed + * [CardAuthorization.AsaRequestFleetInfo] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun fleetInfo(fleetInfo: JsonField) = apply { + fun fleetInfo(fleetInfo: JsonField) = apply { this.fleetInfo = fleetInfo } /** * The latest Authorization Challenge that was issued to the cardholder for this merchant. */ - fun latestChallenge(latestChallenge: LatestChallenge) = + fun latestChallenge(latestChallenge: CardAuthorization.LatestChallenge) = latestChallenge(JsonField.of(latestChallenge)) /** * Sets [Builder.latestChallenge] to an arbitrary JSON value. * - * You should usually call [Builder.latestChallenge] with a well-typed [LatestChallenge] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.latestChallenge] with a well-typed + * [CardAuthorization.LatestChallenge] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun latestChallenge(latestChallenge: JsonField) = apply { + fun latestChallenge(latestChallenge: JsonField) = apply { this.latestChallenge = latestChallenge } /** Card network of the authorization. */ - fun network(network: Network) = network(JsonField.of(network)) + fun network(network: CardAuthorization.Network) = network(JsonField.of(network)) /** * Sets [Builder.network] to an arbitrary JSON value. * - * You should usually call [Builder.network] with a well-typed [Network] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.network] with a well-typed [CardAuthorization.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 } + fun network(network: JsonField) = apply { + this.network = network + } /** * Network-provided score assessing risk level associated with a given authorization. Scores @@ -1280,35 +1340,37 @@ private constructor( * only available to certain programs- contact your Customer Success Manager to discuss * enabling access. */ - fun networkSpecificData(networkSpecificData: AsaNetworkSpecificData?) = + fun networkSpecificData(networkSpecificData: CardAuthorization.AsaNetworkSpecificData?) = networkSpecificData(JsonField.ofNullable(networkSpecificData)) /** * Alias for calling [Builder.networkSpecificData] with `networkSpecificData.orElse(null)`. */ - fun networkSpecificData(networkSpecificData: Optional) = - networkSpecificData(networkSpecificData.getOrNull()) + fun networkSpecificData( + networkSpecificData: Optional + ) = networkSpecificData(networkSpecificData.getOrNull()) /** * Sets [Builder.networkSpecificData] to an arbitrary JSON value. * * You should usually call [Builder.networkSpecificData] with a well-typed - * [AsaNetworkSpecificData] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * [CardAuthorization.AsaNetworkSpecificData] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun networkSpecificData(networkSpecificData: JsonField) = apply { - this.networkSpecificData = networkSpecificData - } + fun networkSpecificData( + networkSpecificData: JsonField + ) = apply { this.networkSpecificData = networkSpecificData } - fun pos(pos: Pos) = pos(JsonField.of(pos)) + fun pos(pos: CardAuthorization.Pos) = pos(JsonField.of(pos)) /** * Sets [Builder.pos] to an arbitrary JSON value. * - * You should usually call [Builder.pos] with a well-typed [Pos] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.pos] with a well-typed [CardAuthorization.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 pos(pos: JsonField) = apply { this.pos = pos } fun tokenInfo(tokenInfo: TokenInfo?) = tokenInfo(JsonField.ofNullable(tokenInfo)) @@ -1336,6 +1398,17 @@ private constructor( */ fun ttl(ttl: JsonField) = apply { this.ttl = ttl } + fun eventType(eventType: EventType) = eventType(JsonField.of(eventType)) + + /** + * Sets [Builder.eventType] to an arbitrary JSON value. + * + * You should usually call [Builder.eventType] with a well-typed [EventType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1372,7 +1445,6 @@ private constructor( * .cardholderCurrency() * .cashAmount() * .created() - * .eventType() * .merchant() * .merchantAmount() * .merchantCurrency() @@ -1380,6 +1452,7 @@ private constructor( * .settledAmount() * .status() * .transactionInitiator() + * .eventType() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1396,7 +1469,6 @@ private constructor( checkRequired("cardholderCurrency", cardholderCurrency), checkRequired("cashAmount", cashAmount), checkRequired("created", created), - checkRequired("eventType", eventType), checkRequired("merchant", merchant), checkRequired("merchantAmount", merchantAmount), checkRequired("merchantCurrency", merchantCurrency), @@ -1417,6 +1489,7 @@ private constructor( pos, tokenInfo, ttl, + checkRequired("eventType", eventType), additionalProperties.toMutableMap(), ) } @@ -1446,7 +1519,6 @@ private constructor( cardholderCurrency() cashAmount() created() - eventType().validate() merchant().validate() merchantAmount() merchantCurrency() @@ -1467,6 +1539,7 @@ private constructor( pos().ifPresent { it.validate() } tokenInfo().ifPresent { it.validate() } ttl() + eventType().validate() validated = true } @@ -1495,7 +1568,6 @@ private constructor( (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + (if (cashAmount.asKnown().isPresent) 1 else 0) + (if (created.asKnown().isPresent) 1 else 0) + - (eventType.asKnown().getOrNull()?.validity() ?: 0) + (merchant.asKnown().getOrNull()?.validity() ?: 0) + (if (merchantAmount.asKnown().isPresent) 1 else 0) + (if (merchantCurrency.asKnown().isPresent) 1 else 0) + @@ -1515,236 +1587,90 @@ private constructor( (networkSpecificData.asKnown().getOrNull()?.validity() ?: 0) + (pos.asKnown().getOrNull()?.validity() ?: 0) + (tokenInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (ttl.asKnown().isPresent) 1 else 0) + (if (ttl.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) - /** - * Structured amounts for this authorization. The `cardholder` and `merchant` amounts reflect - * the original network authorization values. For programs with hold adjustments enabled (e.g., - * automated fuel dispensers or tipping MCCs), the `hold` amount may exceed the `cardholder` and - * `merchant` amounts to account for anticipated final transaction amounts such as tips or fuel - * fill-ups - */ - class Amounts - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cardholder: JsonField, - private val hold: JsonField, - private val merchant: JsonField, - private val settlement: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cardholder") - @ExcludeMissing - cardholder: JsonField = JsonMissing.of(), - @JsonProperty("hold") @ExcludeMissing hold: JsonField = JsonMissing.of(), - @JsonProperty("merchant") - @ExcludeMissing - merchant: JsonField = JsonMissing.of(), - @JsonProperty("settlement") - @ExcludeMissing - settlement: JsonField = JsonMissing.of(), - ) : this(cardholder, hold, merchant, settlement, mutableMapOf()) + class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** - * @throws LithicInvalidDataException 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 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. */ - fun cardholder(): ConvertedAmount = cardholder.getRequired("cardholder") + @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 hold(): Optional = hold.getOptional("hold") + companion object { - /** - * @throws LithicInvalidDataException if 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(): Amount = merchant.getRequired("merchant") + @JvmField + val CARD_AUTHORIZATION_APPROVAL_REQUEST = of("card_authorization.approval_request") - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun settlement(): Optional = settlement.getOptional("settlement") + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_AUTHORIZATION_APPROVAL_REQUEST + } /** - * Returns the raw JSON value of [cardholder]. + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. * - * Unlike [cardholder], this method doesn't throw if the JSON field has an unexpected type. + * An instance of [EventType] 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. */ - @JsonProperty("cardholder") - @ExcludeMissing - fun _cardholder(): JsonField = cardholder + enum class Value { + CARD_AUTHORIZATION_APPROVAL_REQUEST, + /** + * An enum member indicating that [EventType] was instantiated with an unknown value. + */ + _UNKNOWN, + } /** - * Returns the raw JSON value of [hold]. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * Unlike [hold], this method doesn't throw if the JSON field has an unexpected type. + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - @JsonProperty("hold") @ExcludeMissing fun _hold(): JsonField = hold + fun value(): Value = + when (this) { + CARD_AUTHORIZATION_APPROVAL_REQUEST -> Value.CARD_AUTHORIZATION_APPROVAL_REQUEST + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [merchant]. + * 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. * - * Unlike [merchant], this method doesn't throw if the JSON field has an unexpected type. + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. */ - @JsonProperty("merchant") @ExcludeMissing fun _merchant(): JsonField = merchant + fun known(): Known = + when (this) { + CARD_AUTHORIZATION_APPROVAL_REQUEST -> Known.CARD_AUTHORIZATION_APPROVAL_REQUEST + else -> throw LithicInvalidDataException("Unknown EventType: $value") + } /** - * Returns the raw JSON value of [settlement]. + * 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. * - * Unlike [settlement], this method doesn't throw if the JSON field has an unexpected type. + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - @JsonProperty("settlement") - @ExcludeMissing - fun _settlement(): JsonField = settlement - - @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 [Amounts]. - * - * The following fields are required: - * ```java - * .cardholder() - * .hold() - * .merchant() - * .settlement() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Amounts]. */ - class Builder internal constructor() { - - private var cardholder: JsonField? = null - private var hold: JsonField? = null - private var merchant: JsonField? = null - private var settlement: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amounts: Amounts) = apply { - cardholder = amounts.cardholder - hold = amounts.hold - merchant = amounts.merchant - settlement = amounts.settlement - additionalProperties = amounts.additionalProperties.toMutableMap() - } - - fun cardholder(cardholder: ConvertedAmount) = cardholder(JsonField.of(cardholder)) - - /** - * Sets [Builder.cardholder] to an arbitrary JSON value. - * - * You should usually call [Builder.cardholder] with a well-typed [ConvertedAmount] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cardholder(cardholder: JsonField) = apply { - this.cardholder = cardholder - } - - fun hold(hold: Amount?) = hold(JsonField.ofNullable(hold)) - - /** Alias for calling [Builder.hold] with `hold.orElse(null)`. */ - fun hold(hold: Optional) = hold(hold.getOrNull()) - - /** - * Sets [Builder.hold] to an arbitrary JSON value. - * - * You should usually call [Builder.hold] with a well-typed [Amount] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun hold(hold: JsonField) = apply { this.hold = hold } - - fun merchant(merchant: Amount) = merchant(JsonField.of(merchant)) - - /** - * Sets [Builder.merchant] to an arbitrary JSON value. - * - * You should usually call [Builder.merchant] with a well-typed [Amount] 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 } - - fun settlement(settlement: Amount?) = settlement(JsonField.ofNullable(settlement)) - - /** Alias for calling [Builder.settlement] with `settlement.orElse(null)`. */ - fun settlement(settlement: Optional) = settlement(settlement.getOrNull()) - - /** - * Sets [Builder.settlement] to an arbitrary JSON value. - * - * You should usually call [Builder.settlement] with a well-typed [Amount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settlement(settlement: JsonField) = apply { this.settlement = settlement } - - 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 [Amounts]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cardholder() - * .hold() - * .merchant() - * .settlement() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Amounts = - Amounts( - checkRequired("cardholder", cardholder), - checkRequired("hold", hold), - checkRequired("merchant", merchant), - checkRequired("settlement", settlement), - additionalProperties.toMutableMap(), - ) - } + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } private var validated: Boolean = false @@ -1757,15 +1683,12 @@ private constructor( * @throws LithicInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): Amounts = apply { + fun validate(): EventType = apply { if (validated) { return@apply } - cardholder().validate() - hold().ifPresent { it.validate() } - merchant().validate() - settlement().ifPresent { it.validate() } + known() validated = true } @@ -1783,7757 +1706,20 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (cardholder.asKnown().getOrNull()?.validity() ?: 0) + - (hold.asKnown().getOrNull()?.validity() ?: 0) + - (merchant.asKnown().getOrNull()?.validity() ?: 0) + - (settlement.asKnown().getOrNull()?.validity() ?: 0) - - class ConvertedAmount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val conversionRate: JsonField, - private val currency: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - ) : this(amount, conversionRate, currency, mutableMapOf()) - - /** - * Amount in the smallest unit of the applicable currency (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") + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Exchange rate used for currency conversion - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun conversionRate(): String = conversionRate.getRequired("conversion_rate") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + return other is EventType && value == other.value + } - /** - * 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 + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * 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 - - @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 [ConvertedAmount]. - * - * The following fields are required: - * ```java - * .amount() - * .conversionRate() - * .currency() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ConvertedAmount]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var conversionRate: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(convertedAmount: ConvertedAmount) = apply { - amount = convertedAmount.amount - conversionRate = convertedAmount.conversionRate - currency = convertedAmount.currency - additionalProperties = convertedAmount.additionalProperties.toMutableMap() - } - - /** Amount in the smallest unit of the applicable currency (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 } - - /** Exchange rate used for currency conversion */ - fun conversionRate(conversionRate: String) = - conversionRate(JsonField.of(conversionRate)) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** 3-character alphabetic ISO 4217 currency */ - 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 } - - 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 [ConvertedAmount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .conversionRate() - * .currency() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ConvertedAmount = - ConvertedAmount( - checkRequired("amount", amount), - checkRequired("conversionRate", conversionRate), - checkRequired("currency", currency), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): ConvertedAmount = apply { - if (validated) { - return@apply - } - - amount() - conversionRate() - currency() - 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 (amount.asKnown().isPresent) 1 else 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConvertedAmount && - amount == other.amount && - conversionRate == other.conversionRate && - currency == other.currency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, conversionRate, currency, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ConvertedAmount{amount=$amount, conversionRate=$conversionRate, currency=$currency, additionalProperties=$additionalProperties}" - } - - class Amount - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - ) : this(amount, currency, mutableMapOf()) - - /** - * Amount in the smallest unit of the applicable currency (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") - - /** - * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @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 [Amount]. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Amount]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amount: Amount) = apply { - this.amount = amount.amount - currency = amount.currency - additionalProperties = amount.additionalProperties.toMutableMap() - } - - /** Amount in the smallest unit of the applicable currency (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 } - - /** 3-character alphabetic ISO 4217 currency */ - 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 } - - 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 [Amount]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Amount = - Amount( - checkRequired("amount", amount), - checkRequired("currency", currency), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Amount = apply { - if (validated) { - return@apply - } - - amount() - currency() - 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 (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Amount && - amount == other.amount && - currency == other.currency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, currency, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Amount{amount=$amount, currency=$currency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Amounts && - cardholder == other.cardholder && - hold == other.hold && - merchant == other.merchant && - settlement == other.settlement && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(cardholder, hold, merchant, settlement, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Amounts{cardholder=$cardholder, hold=$hold, merchant=$merchant, settlement=$settlement, additionalProperties=$additionalProperties}" - } - - class Avs - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val address: JsonField, - private val addressOnFileMatch: JsonField, - private val zipcode: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("address") @ExcludeMissing address: JsonField = JsonMissing.of(), - @JsonProperty("address_on_file_match") - @ExcludeMissing - addressOnFileMatch: JsonField = JsonMissing.of(), - @JsonProperty("zipcode") @ExcludeMissing zipcode: JsonField = JsonMissing.of(), - ) : this(address, addressOnFileMatch, zipcode, mutableMapOf()) - - /** - * Cardholder address - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun address(): String = address.getRequired("address") - - /** - * Lithic's evaluation result comparing the transaction's address data with the cardholder - * KYC data if it exists. In the event Lithic does not have any Cardholder KYC data, or the - * transaction does not contain any address data, NOT_PRESENT will be returned - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun addressOnFileMatch(): AddressMatchResult = - addressOnFileMatch.getRequired("address_on_file_match") - - /** - * Cardholder ZIP code - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun zipcode(): String = zipcode.getRequired("zipcode") - - /** - * Returns the raw JSON value of [address]. - * - * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address - - /** - * Returns the raw JSON value of [addressOnFileMatch]. - * - * Unlike [addressOnFileMatch], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("address_on_file_match") - @ExcludeMissing - fun _addressOnFileMatch(): JsonField = addressOnFileMatch - - /** - * Returns the raw JSON value of [zipcode]. - * - * Unlike [zipcode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("zipcode") @ExcludeMissing fun _zipcode(): JsonField = zipcode - - @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 [Avs]. - * - * The following fields are required: - * ```java - * .address() - * .addressOnFileMatch() - * .zipcode() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Avs]. */ - class Builder internal constructor() { - - private var address: JsonField? = null - private var addressOnFileMatch: JsonField? = null - private var zipcode: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(avs: Avs) = apply { - address = avs.address - addressOnFileMatch = avs.addressOnFileMatch - zipcode = avs.zipcode - additionalProperties = avs.additionalProperties.toMutableMap() - } - - /** Cardholder address */ - fun address(address: String) = address(JsonField.of(address)) - - /** - * Sets [Builder.address] to an arbitrary JSON value. - * - * You should usually call [Builder.address] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun address(address: JsonField) = apply { this.address = address } - - /** - * Lithic's evaluation result comparing the transaction's address data with the - * cardholder KYC data if it exists. In the event Lithic does not have any Cardholder - * KYC data, or the transaction does not contain any address data, NOT_PRESENT will be - * returned - */ - fun addressOnFileMatch(addressOnFileMatch: AddressMatchResult) = - addressOnFileMatch(JsonField.of(addressOnFileMatch)) - - /** - * Sets [Builder.addressOnFileMatch] to an arbitrary JSON value. - * - * You should usually call [Builder.addressOnFileMatch] with a well-typed - * [AddressMatchResult] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun addressOnFileMatch(addressOnFileMatch: JsonField) = apply { - this.addressOnFileMatch = addressOnFileMatch - } - - /** Cardholder ZIP code */ - fun zipcode(zipcode: String) = zipcode(JsonField.of(zipcode)) - - /** - * Sets [Builder.zipcode] to an arbitrary JSON value. - * - * You should usually call [Builder.zipcode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun zipcode(zipcode: JsonField) = apply { this.zipcode = zipcode } - - 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 [Avs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .address() - * .addressOnFileMatch() - * .zipcode() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Avs = - Avs( - checkRequired("address", address), - checkRequired("addressOnFileMatch", addressOnFileMatch), - checkRequired("zipcode", zipcode), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Avs = apply { - if (validated) { - return@apply - } - - address() - addressOnFileMatch().validate() - zipcode() - 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 (address.asKnown().isPresent) 1 else 0) + - (addressOnFileMatch.asKnown().getOrNull()?.validity() ?: 0) + - (if (zipcode.asKnown().isPresent) 1 else 0) - - /** - * Lithic's evaluation result comparing the transaction's address data with the cardholder - * KYC data if it exists. In the event Lithic does not have any Cardholder KYC data, or the - * transaction does not contain any address data, NOT_PRESENT will be returned - */ - class AddressMatchResult - @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 MATCH = of("MATCH") - - @JvmField val MATCH_ADDRESS_ONLY = of("MATCH_ADDRESS_ONLY") - - @JvmField val MATCH_ZIP_ONLY = of("MATCH_ZIP_ONLY") - - @JvmField val MISMATCH = of("MISMATCH") - - @JvmField val NOT_PRESENT = of("NOT_PRESENT") - - @JvmStatic fun of(value: String) = AddressMatchResult(JsonField.of(value)) - } - - /** An enum containing [AddressMatchResult]'s known values. */ - enum class Known { - MATCH, - MATCH_ADDRESS_ONLY, - MATCH_ZIP_ONLY, - MISMATCH, - NOT_PRESENT, - } - - /** - * An enum containing [AddressMatchResult]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AddressMatchResult] 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 { - MATCH, - MATCH_ADDRESS_ONLY, - MATCH_ZIP_ONLY, - MISMATCH, - NOT_PRESENT, - /** - * An enum member indicating that [AddressMatchResult] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATCH -> Value.MATCH - MATCH_ADDRESS_ONLY -> Value.MATCH_ADDRESS_ONLY - MATCH_ZIP_ONLY -> Value.MATCH_ZIP_ONLY - MISMATCH -> Value.MISMATCH - NOT_PRESENT -> Value.NOT_PRESENT - 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) { - MATCH -> Known.MATCH - MATCH_ADDRESS_ONLY -> Known.MATCH_ADDRESS_ONLY - MATCH_ZIP_ONLY -> Known.MATCH_ZIP_ONLY - MISMATCH -> Known.MISMATCH - NOT_PRESENT -> Known.NOT_PRESENT - else -> throw LithicInvalidDataException("Unknown AddressMatchResult: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AddressMatchResult = 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 AddressMatchResult && 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 Avs && - address == other.address && - addressOnFileMatch == other.addressOnFileMatch && - zipcode == other.zipcode && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(address, addressOnFileMatch, zipcode, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Avs{address=$address, addressOnFileMatch=$addressOnFileMatch, zipcode=$zipcode, additionalProperties=$additionalProperties}" - } - - /** Card object in ASA */ - class AsaRequestCard - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val token: JsonField, - private val lastFour: JsonField, - private val memo: JsonField, - private val spendLimit: JsonField, - private val spendLimitDuration: JsonField, - private val state: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("last_four") - @ExcludeMissing - lastFour: JsonField = JsonMissing.of(), - @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), - @JsonProperty("spend_limit") - @ExcludeMissing - spendLimit: JsonField = JsonMissing.of(), - @JsonProperty("spend_limit_duration") - @ExcludeMissing - spendLimitDuration: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(token, lastFour, memo, spendLimit, spendLimitDuration, state, type, mutableMapOf()) - - /** - * Globally unique identifier for the card. - * - * @throws LithicInvalidDataException if 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") - - /** - * Last four digits of the card number - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lastFour(): String = lastFour.getRequired("last_four") - - /** - * Customizable name to identify the card - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun memo(): String = memo.getRequired("memo") - - /** - * Amount (in cents) to limit approved authorizations. Purchase requests above the spend - * limit will be declined (refunds and credits will be approved). - * - * Note that while spend limits are enforced based on authorized and settled volume on a - * card, they are not recommended to be used for balance or reconciliation-level accuracy. - * Spend limits also cannot block force posted charges (i.e., when a merchant sends a - * clearing message without a prior authorization). - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun spendLimit(): Long = spendLimit.getRequired("spend_limit") - - /** - * Note that to support recurring monthly payments, which can occur on different day every - * month, the time window we consider for MONTHLY velocity starts 6 days after the current - * calendar date one month prior. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun spendLimitDuration(): SpendLimitDuration = - spendLimitDuration.getRequired("spend_limit_duration") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun state(): State = state.getRequired("state") - - /** - * @throws LithicInvalidDataException if 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(): CardType = type.getRequired("type") - - /** - * 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 [lastFour]. - * - * Unlike [lastFour], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour - - /** - * Returns the raw JSON value of [memo]. - * - * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * Returns the raw JSON value of [spendLimit]. - * - * Unlike [spendLimit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit(): JsonField = spendLimit - - /** - * Returns the raw JSON value of [spendLimitDuration]. - * - * Unlike [spendLimitDuration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("spend_limit_duration") - @ExcludeMissing - fun _spendLimitDuration(): JsonField = spendLimitDuration - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AsaRequestCard]. - * - * The following fields are required: - * ```java - * .token() - * .lastFour() - * .memo() - * .spendLimit() - * .spendLimitDuration() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaRequestCard]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var lastFour: JsonField? = null - private var memo: JsonField? = null - private var spendLimit: JsonField? = null - private var spendLimitDuration: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(asaRequestCard: AsaRequestCard) = apply { - token = asaRequestCard.token - lastFour = asaRequestCard.lastFour - memo = asaRequestCard.memo - spendLimit = asaRequestCard.spendLimit - spendLimitDuration = asaRequestCard.spendLimitDuration - state = asaRequestCard.state - type = asaRequestCard.type - additionalProperties = asaRequestCard.additionalProperties.toMutableMap() - } - - /** Globally unique identifier for the card. */ - 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 } - - /** Last four digits of the card number */ - fun lastFour(lastFour: String) = lastFour(JsonField.of(lastFour)) - - /** - * Sets [Builder.lastFour] to an arbitrary JSON value. - * - * You should usually call [Builder.lastFour] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lastFour(lastFour: JsonField) = apply { this.lastFour = lastFour } - - /** Customizable name to identify the card */ - fun memo(memo: String) = memo(JsonField.of(memo)) - - /** - * Sets [Builder.memo] to an arbitrary JSON value. - * - * 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 memo(memo: JsonField) = apply { this.memo = memo } - - /** - * Amount (in cents) to limit approved authorizations. Purchase requests above the spend - * limit will be declined (refunds and credits will be approved). - * - * Note that while spend limits are enforced based on authorized and settled volume on a - * card, they are not recommended to be used for balance or reconciliation-level - * accuracy. Spend limits also cannot block force posted charges (i.e., when a merchant - * sends a clearing message without a prior authorization). - */ - fun spendLimit(spendLimit: Long) = spendLimit(JsonField.of(spendLimit)) - - /** - * Sets [Builder.spendLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.spendLimit] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun spendLimit(spendLimit: JsonField) = apply { this.spendLimit = spendLimit } - - /** - * Note that to support recurring monthly payments, which can occur on different day - * every month, the time window we consider for MONTHLY velocity starts 6 days after the - * current calendar date one month prior. - */ - fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = - spendLimitDuration(JsonField.of(spendLimitDuration)) - - /** - * Sets [Builder.spendLimitDuration] to an arbitrary JSON value. - * - * You should usually call [Builder.spendLimitDuration] with a well-typed - * [SpendLimitDuration] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun spendLimitDuration(spendLimitDuration: JsonField) = apply { - this.spendLimitDuration = spendLimitDuration - } - - fun state(state: State) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [State] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun state(state: JsonField) = apply { this.state = state } - - fun type(type: CardType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [CardType] 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 [AsaRequestCard]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .lastFour() - * .memo() - * .spendLimit() - * .spendLimitDuration() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AsaRequestCard = - AsaRequestCard( - checkRequired("token", token), - checkRequired("lastFour", lastFour), - checkRequired("memo", memo), - checkRequired("spendLimit", spendLimit), - checkRequired("spendLimitDuration", spendLimitDuration), - checkRequired("state", state), - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaRequestCard = apply { - if (validated) { - return@apply - } - - token() - lastFour() - memo() - spendLimit() - spendLimitDuration().validate() - state().validate() - type().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 (lastFour.asKnown().isPresent) 1 else 0) + - (if (memo.asKnown().isPresent) 1 else 0) + - (if (spendLimit.asKnown().isPresent) 1 else 0) + - (spendLimitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Note that to support recurring monthly payments, which can occur on different day every - * month, the time window we consider for MONTHLY velocity starts 6 days after the current - * calendar date one month prior. - */ - class SpendLimitDuration - @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 ANNUALLY = of("ANNUALLY") - - @JvmField val FOREVER = of("FOREVER") - - @JvmField val MONTHLY = of("MONTHLY") - - @JvmField val TRANSACTION = of("TRANSACTION") - - @JvmStatic fun of(value: String) = SpendLimitDuration(JsonField.of(value)) - } - - /** An enum containing [SpendLimitDuration]'s known values. */ - enum class Known { - ANNUALLY, - FOREVER, - MONTHLY, - TRANSACTION, - } - - /** - * An enum containing [SpendLimitDuration]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [SpendLimitDuration] 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 { - ANNUALLY, - FOREVER, - MONTHLY, - TRANSACTION, - /** - * An enum member indicating that [SpendLimitDuration] 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) { - ANNUALLY -> Value.ANNUALLY - FOREVER -> Value.FOREVER - MONTHLY -> Value.MONTHLY - TRANSACTION -> Value.TRANSACTION - 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) { - ANNUALLY -> Known.ANNUALLY - FOREVER -> Known.FOREVER - MONTHLY -> Known.MONTHLY - TRANSACTION -> Known.TRANSACTION - else -> throw LithicInvalidDataException("Unknown SpendLimitDuration: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): SpendLimitDuration = 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 SpendLimitDuration && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class State @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 CLOSED = of("CLOSED") - - @JvmField val OPEN = of("OPEN") - - @JvmField val PAUSED = of("PAUSED") - - @JvmField val PENDING_ACTIVATION = of("PENDING_ACTIVATION") - - @JvmField val PENDING_FULFILLMENT = of("PENDING_FULFILLMENT") - - @JvmStatic fun of(value: String) = State(JsonField.of(value)) - } - - /** An enum containing [State]'s known values. */ - enum class Known { - CLOSED, - OPEN, - PAUSED, - PENDING_ACTIVATION, - PENDING_FULFILLMENT, - } - - /** - * An enum containing [State]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [State] 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 { - CLOSED, - OPEN, - PAUSED, - PENDING_ACTIVATION, - PENDING_FULFILLMENT, - /** - * An enum member indicating that [State] 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) { - CLOSED -> Value.CLOSED - OPEN -> Value.OPEN - PAUSED -> Value.PAUSED - PENDING_ACTIVATION -> Value.PENDING_ACTIVATION - PENDING_FULFILLMENT -> Value.PENDING_FULFILLMENT - 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) { - CLOSED -> Known.CLOSED - OPEN -> Known.OPEN - PAUSED -> Known.PAUSED - PENDING_ACTIVATION -> Known.PENDING_ACTIVATION - PENDING_FULFILLMENT -> Known.PENDING_FULFILLMENT - else -> throw LithicInvalidDataException("Unknown State: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): State = 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 State && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class CardType @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 SINGLE_USE = of("SINGLE_USE") - - @JvmField val MERCHANT_LOCKED = of("MERCHANT_LOCKED") - - @JvmField val UNLOCKED = of("UNLOCKED") - - @JvmField val PHYSICAL = of("PHYSICAL") - - @JvmField val DIGITAL_WALLET = of("DIGITAL_WALLET") - - @JvmField val VIRTUAL = of("VIRTUAL") - - @JvmStatic fun of(value: String) = CardType(JsonField.of(value)) - } - - /** An enum containing [CardType]'s known values. */ - enum class Known { - SINGLE_USE, - MERCHANT_LOCKED, - UNLOCKED, - PHYSICAL, - DIGITAL_WALLET, - VIRTUAL, - } - - /** - * An enum containing [CardType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [CardType] 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 { - SINGLE_USE, - MERCHANT_LOCKED, - UNLOCKED, - PHYSICAL, - DIGITAL_WALLET, - VIRTUAL, - /** - * An enum member indicating that [CardType] 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) { - SINGLE_USE -> Value.SINGLE_USE - MERCHANT_LOCKED -> Value.MERCHANT_LOCKED - UNLOCKED -> Value.UNLOCKED - PHYSICAL -> Value.PHYSICAL - DIGITAL_WALLET -> Value.DIGITAL_WALLET - VIRTUAL -> Value.VIRTUAL - 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) { - SINGLE_USE -> Known.SINGLE_USE - MERCHANT_LOCKED -> Known.MERCHANT_LOCKED - UNLOCKED -> Known.UNLOCKED - PHYSICAL -> Known.PHYSICAL - DIGITAL_WALLET -> Known.DIGITAL_WALLET - VIRTUAL -> Known.VIRTUAL - else -> throw LithicInvalidDataException("Unknown CardType: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): CardType = 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 CardType && 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 AsaRequestCard && - token == other.token && - lastFour == other.lastFour && - memo == other.memo && - spendLimit == other.spendLimit && - spendLimitDuration == other.spendLimitDuration && - state == other.state && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - lastFour, - memo, - spendLimit, - spendLimitDuration, - state, - type, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaRequestCard{token=$token, lastFour=$lastFour, memo=$memo, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, additionalProperties=$additionalProperties}" - } - - class EventType @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_AUTHORIZATION_APPROVAL_REQUEST = of("card_authorization.approval_request") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - CARD_AUTHORIZATION_APPROVAL_REQUEST - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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_AUTHORIZATION_APPROVAL_REQUEST, - /** - * An enum member indicating that [EventType] 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_AUTHORIZATION_APPROVAL_REQUEST -> Value.CARD_AUTHORIZATION_APPROVAL_REQUEST - 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_AUTHORIZATION_APPROVAL_REQUEST -> Known.CARD_AUTHORIZATION_APPROVAL_REQUEST - else -> throw LithicInvalidDataException("Unknown EventType: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Merchant information including full location details. */ - class TransactionMerchant - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val acceptorId: JsonField, - private val acquiringInstitutionId: JsonField, - private val city: JsonField, - private val country: JsonField, - private val descriptor: JsonField, - private val mcc: JsonField, - private val state: JsonField, - private val phoneNumber: JsonField, - private val postalCode: JsonField, - private val streetAddress: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("acceptor_id") - @ExcludeMissing - acceptorId: JsonField = JsonMissing.of(), - @JsonProperty("acquiring_institution_id") - @ExcludeMissing - acquiringInstitutionId: JsonField = JsonMissing.of(), - @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), - @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), - @JsonProperty("descriptor") - @ExcludeMissing - descriptor: JsonField = JsonMissing.of(), - @JsonProperty("mcc") @ExcludeMissing mcc: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("phone_number") - @ExcludeMissing - phoneNumber: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - postalCode: JsonField = JsonMissing.of(), - @JsonProperty("street_address") - @ExcludeMissing - streetAddress: JsonField = JsonMissing.of(), - ) : this( - acceptorId, - acquiringInstitutionId, - city, - country, - descriptor, - mcc, - state, - phoneNumber, - postalCode, - streetAddress, - mutableMapOf(), - ) - - fun toMerchant(): Merchant = - Merchant.builder() - .acceptorId(acceptorId) - .acquiringInstitutionId(acquiringInstitutionId) - .city(city) - .country(country) - .descriptor(descriptor) - .mcc(mcc) - .state(state) - .build() - - /** - * Unique alphanumeric identifier for the payment card acceptor (merchant). - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun acceptorId(): String = acceptorId.getRequired("acceptor_id") - - /** - * Unique numeric identifier of the acquiring institution. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun acquiringInstitutionId(): String = - acquiringInstitutionId.getRequired("acquiring_institution_id") - - /** - * City of card acceptor. Note that in many cases, particularly in card-not-present - * transactions, merchants may send through a phone number or URL in this field. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun city(): String = city.getRequired("city") - - /** - * Country or entity of card acceptor. Possible values are: (1) all ISO 3166-1 alpha-3 - * country codes, (2) QZZ for Kosovo, and (3) ANT for Netherlands Antilles. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun country(): String = country.getRequired("country") - - /** - * Short description of card acceptor. - * - * @throws LithicInvalidDataException if 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") - - /** - * Merchant category code (MCC). A four-digit number listed in ISO 18245. An MCC is used to - * classify a business by the types of goods or services it provides. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun mcc(): String = mcc.getRequired("mcc") - - /** - * Geographic state of card acceptor. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun state(): String = state.getRequired("state") - - /** - * Phone number of card acceptor. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") - - /** - * Postal code of card acceptor. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun postalCode(): Optional = postalCode.getOptional("postal_code") - - /** - * Street address of card acceptor. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun streetAddress(): Optional = streetAddress.getOptional("street_address") - - /** - * Returns the raw JSON value of [acceptorId]. - * - * Unlike [acceptorId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("acceptor_id") - @ExcludeMissing - fun _acceptorId(): JsonField = acceptorId - - /** - * Returns the raw JSON value of [acquiringInstitutionId]. - * - * Unlike [acquiringInstitutionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("acquiring_institution_id") - @ExcludeMissing - fun _acquiringInstitutionId(): JsonField = acquiringInstitutionId - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [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 [mcc]. - * - * Unlike [mcc], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - /** - * Returns the raw JSON value of [phoneNumber]. - * - * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("phone_number") - @ExcludeMissing - fun _phoneNumber(): JsonField = phoneNumber - - /** - * Returns the raw JSON value of [postalCode]. - * - * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - /** - * Returns the raw JSON value of [streetAddress]. - * - * Unlike [streetAddress], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("street_address") - @ExcludeMissing - fun _streetAddress(): JsonField = streetAddress - - @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 [TransactionMerchant]. - * - * The following fields are required: - * ```java - * .acceptorId() - * .acquiringInstitutionId() - * .city() - * .country() - * .descriptor() - * .mcc() - * .state() - * .phoneNumber() - * .postalCode() - * .streetAddress() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TransactionMerchant]. */ - class Builder internal constructor() { - - private var acceptorId: JsonField? = null - private var acquiringInstitutionId: JsonField? = null - private var city: JsonField? = null - private var country: JsonField? = null - private var descriptor: JsonField? = null - private var mcc: JsonField? = null - private var state: JsonField? = null - private var phoneNumber: JsonField? = null - private var postalCode: JsonField? = null - private var streetAddress: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(transactionMerchant: TransactionMerchant) = apply { - acceptorId = transactionMerchant.acceptorId - acquiringInstitutionId = transactionMerchant.acquiringInstitutionId - city = transactionMerchant.city - country = transactionMerchant.country - descriptor = transactionMerchant.descriptor - mcc = transactionMerchant.mcc - state = transactionMerchant.state - phoneNumber = transactionMerchant.phoneNumber - postalCode = transactionMerchant.postalCode - streetAddress = transactionMerchant.streetAddress - additionalProperties = transactionMerchant.additionalProperties.toMutableMap() - } - - /** Unique alphanumeric identifier for the payment card acceptor (merchant). */ - fun acceptorId(acceptorId: String) = acceptorId(JsonField.of(acceptorId)) - - /** - * Sets [Builder.acceptorId] to an arbitrary JSON value. - * - * You should usually call [Builder.acceptorId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun acceptorId(acceptorId: JsonField) = apply { this.acceptorId = acceptorId } - - /** Unique numeric identifier of the acquiring institution. */ - fun acquiringInstitutionId(acquiringInstitutionId: String) = - acquiringInstitutionId(JsonField.of(acquiringInstitutionId)) - - /** - * Sets [Builder.acquiringInstitutionId] to an arbitrary JSON value. - * - * You should usually call [Builder.acquiringInstitutionId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun acquiringInstitutionId(acquiringInstitutionId: JsonField) = apply { - this.acquiringInstitutionId = acquiringInstitutionId - } - - /** - * City of card acceptor. Note that in many cases, particularly in card-not-present - * transactions, merchants may send through a phone number or URL in this field. - */ - fun city(city: String) = city(JsonField.of(city)) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun city(city: JsonField) = apply { this.city = city } - - /** - * Country or entity of card acceptor. Possible values are: (1) all ISO 3166-1 alpha-3 - * country codes, (2) QZZ for Kosovo, and (3) ANT for Netherlands Antilles. - */ - fun country(country: String) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - /** Short description of card acceptor. */ - 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 } - - /** - * Merchant category code (MCC). A four-digit number listed in ISO 18245. An MCC is used - * to classify a business by the types of goods or services it provides. - */ - fun mcc(mcc: String) = mcc(JsonField.of(mcc)) - - /** - * Sets [Builder.mcc] to an arbitrary JSON value. - * - * You should usually call [Builder.mcc] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun mcc(mcc: JsonField) = apply { this.mcc = mcc } - - /** Geographic state of card acceptor. */ - fun state(state: String) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - /** Phone number of card acceptor. */ - fun phoneNumber(phoneNumber: String?) = phoneNumber(JsonField.ofNullable(phoneNumber)) - - /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ - fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.getOrNull()) - - /** - * Sets [Builder.phoneNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.phoneNumber] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun phoneNumber(phoneNumber: JsonField) = apply { - this.phoneNumber = phoneNumber - } - - /** Postal code of card acceptor. */ - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - /** Alias for calling [Builder.postalCode] with `postalCode.orElse(null)`. */ - fun postalCode(postalCode: Optional) = postalCode(postalCode.getOrNull()) - - /** - * Sets [Builder.postalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.postalCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - /** Street address of card acceptor. */ - fun streetAddress(streetAddress: String?) = - streetAddress(JsonField.ofNullable(streetAddress)) - - /** Alias for calling [Builder.streetAddress] with `streetAddress.orElse(null)`. */ - fun streetAddress(streetAddress: Optional) = - streetAddress(streetAddress.getOrNull()) - - /** - * Sets [Builder.streetAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.streetAddress] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun streetAddress(streetAddress: JsonField) = apply { - this.streetAddress = streetAddress - } - - 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 [TransactionMerchant]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .acceptorId() - * .acquiringInstitutionId() - * .city() - * .country() - * .descriptor() - * .mcc() - * .state() - * .phoneNumber() - * .postalCode() - * .streetAddress() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TransactionMerchant = - TransactionMerchant( - checkRequired("acceptorId", acceptorId), - checkRequired("acquiringInstitutionId", acquiringInstitutionId), - checkRequired("city", city), - checkRequired("country", country), - checkRequired("descriptor", descriptor), - checkRequired("mcc", mcc), - checkRequired("state", state), - checkRequired("phoneNumber", phoneNumber), - checkRequired("postalCode", postalCode), - checkRequired("streetAddress", streetAddress), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): TransactionMerchant = apply { - if (validated) { - return@apply - } - - acceptorId() - acquiringInstitutionId() - city() - country() - descriptor() - mcc() - state() - phoneNumber() - postalCode() - streetAddress() - 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 (acceptorId.asKnown().isPresent) 1 else 0) + - (if (acquiringInstitutionId.asKnown().isPresent) 1 else 0) + - (if (city.asKnown().isPresent) 1 else 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (descriptor.asKnown().isPresent) 1 else 0) + - (if (mcc.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + - (if (phoneNumber.asKnown().isPresent) 1 else 0) + - (if (postalCode.asKnown().isPresent) 1 else 0) + - (if (streetAddress.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TransactionMerchant && - acceptorId == other.acceptorId && - acquiringInstitutionId == other.acquiringInstitutionId && - city == other.city && - country == other.country && - descriptor == other.descriptor && - mcc == other.mcc && - state == other.state && - phoneNumber == other.phoneNumber && - postalCode == other.postalCode && - streetAddress == other.streetAddress && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - acceptorId, - acquiringInstitutionId, - city, - country, - descriptor, - mcc, - state, - phoneNumber, - postalCode, - streetAddress, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TransactionMerchant{acceptorId=$acceptorId, acquiringInstitutionId=$acquiringInstitutionId, city=$city, country=$country, descriptor=$descriptor, mcc=$mcc, state=$state, phoneNumber=$phoneNumber, postalCode=$postalCode, streetAddress=$streetAddress, additionalProperties=$additionalProperties}" - } - - /** - * Where the cardholder received the service, when different from the card acceptor location. - * This is populated from network data elements such as Mastercard DE-122 SE1 SF9-14 and Visa - * F34 DS02. - */ - class ServiceLocation - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val city: JsonField, - private val country: JsonField, - private val postalCode: JsonField, - private val state: JsonField, - private val streetAddress: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), - @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("street_address") - @ExcludeMissing - streetAddress: JsonField = JsonMissing.of(), - ) : this(city, country, postalCode, state, streetAddress, mutableMapOf()) - - /** - * City of service location. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("city") - - /** - * Country code of service location, ISO 3166-1 alpha-3. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun country(): Optional = country.getOptional("country") - - /** - * Postal code of service location. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun postalCode(): Optional = postalCode.getOptional("postal_code") - - /** - * State/province code of service location, ISO 3166-2. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun state(): Optional = state.getOptional("state") - - /** - * Street address of service location. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun streetAddress(): Optional = streetAddress.getOptional("street_address") - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [postalCode]. - * - * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - /** - * Returns the raw JSON value of [streetAddress]. - * - * Unlike [streetAddress], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("street_address") - @ExcludeMissing - fun _streetAddress(): JsonField = streetAddress - - @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 [ServiceLocation]. - * - * The following fields are required: - * ```java - * .city() - * .country() - * .postalCode() - * .state() - * .streetAddress() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ServiceLocation]. */ - class Builder internal constructor() { - - private var city: JsonField? = null - private var country: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null - private var streetAddress: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(serviceLocation: ServiceLocation) = apply { - city = serviceLocation.city - country = serviceLocation.country - postalCode = serviceLocation.postalCode - state = serviceLocation.state - streetAddress = serviceLocation.streetAddress - additionalProperties = serviceLocation.additionalProperties.toMutableMap() - } - - /** City of service location. */ - fun city(city: String?) = city(JsonField.ofNullable(city)) - - /** Alias for calling [Builder.city] with `city.orElse(null)`. */ - fun city(city: Optional) = city(city.getOrNull()) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun city(city: JsonField) = apply { this.city = city } - - /** Country code of service location, ISO 3166-1 alpha-3. */ - fun country(country: String?) = country(JsonField.ofNullable(country)) - - /** Alias for calling [Builder.country] with `country.orElse(null)`. */ - fun country(country: Optional) = country(country.getOrNull()) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - /** Postal code of service location. */ - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - /** Alias for calling [Builder.postalCode] with `postalCode.orElse(null)`. */ - fun postalCode(postalCode: Optional) = postalCode(postalCode.getOrNull()) - - /** - * Sets [Builder.postalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.postalCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - /** State/province code of service location, ISO 3166-2. */ - fun state(state: String?) = state(JsonField.ofNullable(state)) - - /** Alias for calling [Builder.state] with `state.orElse(null)`. */ - fun state(state: Optional) = state(state.getOrNull()) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - /** Street address of service location. */ - fun streetAddress(streetAddress: String?) = - streetAddress(JsonField.ofNullable(streetAddress)) - - /** Alias for calling [Builder.streetAddress] with `streetAddress.orElse(null)`. */ - fun streetAddress(streetAddress: Optional) = - streetAddress(streetAddress.getOrNull()) - - /** - * Sets [Builder.streetAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.streetAddress] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun streetAddress(streetAddress: JsonField) = apply { - this.streetAddress = streetAddress - } - - 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 [ServiceLocation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .city() - * .country() - * .postalCode() - * .state() - * .streetAddress() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ServiceLocation = - ServiceLocation( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("postalCode", postalCode), - checkRequired("state", state), - checkRequired("streetAddress", streetAddress), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): ServiceLocation = apply { - if (validated) { - return@apply - } - - city() - country() - postalCode() - state() - streetAddress() - 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 (city.asKnown().isPresent) 1 else 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (postalCode.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + - (if (streetAddress.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ServiceLocation && - city == other.city && - country == other.country && - postalCode == other.postalCode && - state == other.state && - streetAddress == other.streetAddress && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(city, country, postalCode, state, streetAddress, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ServiceLocation{city=$city, country=$country, postalCode=$postalCode, state=$state, streetAddress=$streetAddress, additionalProperties=$additionalProperties}" - } - - /** - * The type of authorization request that this request is for. Note that `CREDIT_AUTHORIZATION` - * and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to users with credit decisioning via - * ASA enabled. - */ - class AsaRequestStatus @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 AUTHORIZATION = of("AUTHORIZATION") - - @JvmField val CREDIT_AUTHORIZATION = of("CREDIT_AUTHORIZATION") - - @JvmField val FINANCIAL_AUTHORIZATION = of("FINANCIAL_AUTHORIZATION") - - @JvmField val FINANCIAL_CREDIT_AUTHORIZATION = of("FINANCIAL_CREDIT_AUTHORIZATION") - - @JvmField val BALANCE_INQUIRY = of("BALANCE_INQUIRY") - - @JvmStatic fun of(value: String) = AsaRequestStatus(JsonField.of(value)) - } - - /** An enum containing [AsaRequestStatus]'s known values. */ - enum class Known { - AUTHORIZATION, - CREDIT_AUTHORIZATION, - FINANCIAL_AUTHORIZATION, - FINANCIAL_CREDIT_AUTHORIZATION, - BALANCE_INQUIRY, - } - - /** - * An enum containing [AsaRequestStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AsaRequestStatus] 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 { - AUTHORIZATION, - CREDIT_AUTHORIZATION, - FINANCIAL_AUTHORIZATION, - FINANCIAL_CREDIT_AUTHORIZATION, - BALANCE_INQUIRY, - /** - * An enum member indicating that [AsaRequestStatus] 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) { - AUTHORIZATION -> Value.AUTHORIZATION - CREDIT_AUTHORIZATION -> Value.CREDIT_AUTHORIZATION - FINANCIAL_AUTHORIZATION -> Value.FINANCIAL_AUTHORIZATION - FINANCIAL_CREDIT_AUTHORIZATION -> Value.FINANCIAL_CREDIT_AUTHORIZATION - BALANCE_INQUIRY -> Value.BALANCE_INQUIRY - 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) { - AUTHORIZATION -> Known.AUTHORIZATION - CREDIT_AUTHORIZATION -> Known.CREDIT_AUTHORIZATION - FINANCIAL_AUTHORIZATION -> Known.FINANCIAL_AUTHORIZATION - FINANCIAL_CREDIT_AUTHORIZATION -> Known.FINANCIAL_CREDIT_AUTHORIZATION - BALANCE_INQUIRY -> Known.BALANCE_INQUIRY - else -> throw LithicInvalidDataException("Unknown AsaRequestStatus: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaRequestStatus = 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 AsaRequestStatus && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The entity that initiated the transaction. */ - class TransactionInitiator - @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 CARDHOLDER = of("CARDHOLDER") - - @JvmField val MERCHANT = of("MERCHANT") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = TransactionInitiator(JsonField.of(value)) - } - - /** An enum containing [TransactionInitiator]'s known values. */ - enum class Known { - CARDHOLDER, - MERCHANT, - UNKNOWN, - } - - /** - * An enum containing [TransactionInitiator]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [TransactionInitiator] 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 { - CARDHOLDER, - MERCHANT, - UNKNOWN, - /** - * An enum member indicating that [TransactionInitiator] 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) { - CARDHOLDER -> Value.CARDHOLDER - MERCHANT -> Value.MERCHANT - UNKNOWN -> Value.UNKNOWN - 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) { - CARDHOLDER -> Known.CARDHOLDER - MERCHANT -> Known.MERCHANT - UNKNOWN -> Known.UNKNOWN - else -> throw LithicInvalidDataException("Unknown TransactionInitiator: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): TransactionInitiator = 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 TransactionInitiator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class AccountType @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 CHECKING = of("CHECKING") - - @JvmField val SAVINGS = of("SAVINGS") - - @JvmStatic fun of(value: String) = AccountType(JsonField.of(value)) - } - - /** An enum containing [AccountType]'s known values. */ - enum class Known { - CHECKING, - SAVINGS, - } - - /** - * An enum containing [AccountType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AccountType] 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 { - CHECKING, - SAVINGS, - /** - * An enum member indicating that [AccountType] 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) { - CHECKING -> Value.CHECKING - SAVINGS -> Value.SAVINGS - 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) { - CHECKING -> Known.CHECKING - SAVINGS -> Known.SAVINGS - else -> throw LithicInvalidDataException("Unknown AccountType: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AccountType = 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 AccountType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Optional Object containing information if the Card is a part of a Fleet managed program */ - class AsaRequestFleetInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val fleetPromptCode: JsonField, - private val fleetRestrictionCode: JsonField, - private val driverNumber: JsonField, - private val vehicleNumber: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("fleet_prompt_code") - @ExcludeMissing - fleetPromptCode: JsonField = JsonMissing.of(), - @JsonProperty("fleet_restriction_code") - @ExcludeMissing - fleetRestrictionCode: JsonField = JsonMissing.of(), - @JsonProperty("driver_number") - @ExcludeMissing - driverNumber: JsonField = JsonMissing.of(), - @JsonProperty("vehicle_number") - @ExcludeMissing - vehicleNumber: JsonField = JsonMissing.of(), - ) : this(fleetPromptCode, fleetRestrictionCode, driverNumber, vehicleNumber, mutableMapOf()) - - /** - * Code indicating what the driver was prompted to enter at time of purchase. This is - * configured at a program level and is a static configuration, and does not change on a - * request to request basis - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun fleetPromptCode(): FleetPromptCode = fleetPromptCode.getRequired("fleet_prompt_code") - - /** - * Code indicating which restrictions, if any, there are on purchase. This is configured at - * a program level and is a static configuration, and does not change on a request to - * request basis - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun fleetRestrictionCode(): FleetRestrictionCode = - fleetRestrictionCode.getRequired("fleet_restriction_code") - - /** - * Number representing the driver - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun driverNumber(): Optional = driverNumber.getOptional("driver_number") - - /** - * Number associated with the vehicle - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun vehicleNumber(): Optional = vehicleNumber.getOptional("vehicle_number") - - /** - * Returns the raw JSON value of [fleetPromptCode]. - * - * Unlike [fleetPromptCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fleet_prompt_code") - @ExcludeMissing - fun _fleetPromptCode(): JsonField = fleetPromptCode - - /** - * Returns the raw JSON value of [fleetRestrictionCode]. - * - * Unlike [fleetRestrictionCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fleet_restriction_code") - @ExcludeMissing - fun _fleetRestrictionCode(): JsonField = fleetRestrictionCode - - /** - * Returns the raw JSON value of [driverNumber]. - * - * Unlike [driverNumber], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("driver_number") - @ExcludeMissing - fun _driverNumber(): JsonField = driverNumber - - /** - * Returns the raw JSON value of [vehicleNumber]. - * - * Unlike [vehicleNumber], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("vehicle_number") - @ExcludeMissing - fun _vehicleNumber(): JsonField = vehicleNumber - - @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 [AsaRequestFleetInfo]. - * - * The following fields are required: - * ```java - * .fleetPromptCode() - * .fleetRestrictionCode() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaRequestFleetInfo]. */ - class Builder internal constructor() { - - private var fleetPromptCode: JsonField? = null - private var fleetRestrictionCode: JsonField? = null - private var driverNumber: JsonField = JsonMissing.of() - private var vehicleNumber: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(asaRequestFleetInfo: AsaRequestFleetInfo) = apply { - fleetPromptCode = asaRequestFleetInfo.fleetPromptCode - fleetRestrictionCode = asaRequestFleetInfo.fleetRestrictionCode - driverNumber = asaRequestFleetInfo.driverNumber - vehicleNumber = asaRequestFleetInfo.vehicleNumber - additionalProperties = asaRequestFleetInfo.additionalProperties.toMutableMap() - } - - /** - * Code indicating what the driver was prompted to enter at time of purchase. This is - * configured at a program level and is a static configuration, and does not change on a - * request to request basis - */ - fun fleetPromptCode(fleetPromptCode: FleetPromptCode) = - fleetPromptCode(JsonField.of(fleetPromptCode)) - - /** - * Sets [Builder.fleetPromptCode] to an arbitrary JSON value. - * - * You should usually call [Builder.fleetPromptCode] with a well-typed [FleetPromptCode] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun fleetPromptCode(fleetPromptCode: JsonField) = apply { - this.fleetPromptCode = fleetPromptCode - } - - /** - * Code indicating which restrictions, if any, there are on purchase. This is configured - * at a program level and is a static configuration, and does not change on a request to - * request basis - */ - fun fleetRestrictionCode(fleetRestrictionCode: FleetRestrictionCode) = - fleetRestrictionCode(JsonField.of(fleetRestrictionCode)) - - /** - * Sets [Builder.fleetRestrictionCode] to an arbitrary JSON value. - * - * You should usually call [Builder.fleetRestrictionCode] with a well-typed - * [FleetRestrictionCode] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun fleetRestrictionCode(fleetRestrictionCode: JsonField) = - apply { - this.fleetRestrictionCode = fleetRestrictionCode - } - - /** Number representing the driver */ - fun driverNumber(driverNumber: String?) = - driverNumber(JsonField.ofNullable(driverNumber)) - - /** Alias for calling [Builder.driverNumber] with `driverNumber.orElse(null)`. */ - fun driverNumber(driverNumber: Optional) = - driverNumber(driverNumber.getOrNull()) - - /** - * Sets [Builder.driverNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.driverNumber] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun driverNumber(driverNumber: JsonField) = apply { - this.driverNumber = driverNumber - } - - /** Number associated with the vehicle */ - fun vehicleNumber(vehicleNumber: String?) = - vehicleNumber(JsonField.ofNullable(vehicleNumber)) - - /** Alias for calling [Builder.vehicleNumber] with `vehicleNumber.orElse(null)`. */ - fun vehicleNumber(vehicleNumber: Optional) = - vehicleNumber(vehicleNumber.getOrNull()) - - /** - * Sets [Builder.vehicleNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.vehicleNumber] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun vehicleNumber(vehicleNumber: JsonField) = apply { - this.vehicleNumber = vehicleNumber - } - - 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 [AsaRequestFleetInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .fleetPromptCode() - * .fleetRestrictionCode() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AsaRequestFleetInfo = - AsaRequestFleetInfo( - checkRequired("fleetPromptCode", fleetPromptCode), - checkRequired("fleetRestrictionCode", fleetRestrictionCode), - driverNumber, - vehicleNumber, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaRequestFleetInfo = apply { - if (validated) { - return@apply - } - - fleetPromptCode().validate() - fleetRestrictionCode().validate() - driverNumber() - vehicleNumber() - 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 = - (fleetPromptCode.asKnown().getOrNull()?.validity() ?: 0) + - (fleetRestrictionCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (driverNumber.asKnown().isPresent) 1 else 0) + - (if (vehicleNumber.asKnown().isPresent) 1 else 0) - - /** - * Code indicating what the driver was prompted to enter at time of purchase. This is - * configured at a program level and is a static configuration, and does not change on a - * request to request basis - */ - class FleetPromptCode - @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 NO_PROMPT = of("NO_PROMPT") - - @JvmField val VEHICLE_NUMBER = of("VEHICLE_NUMBER") - - @JvmField val DRIVER_NUMBER = of("DRIVER_NUMBER") - - @JvmStatic fun of(value: String) = FleetPromptCode(JsonField.of(value)) - } - - /** An enum containing [FleetPromptCode]'s known values. */ - enum class Known { - NO_PROMPT, - VEHICLE_NUMBER, - DRIVER_NUMBER, - } - - /** - * An enum containing [FleetPromptCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [FleetPromptCode] 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 { - NO_PROMPT, - VEHICLE_NUMBER, - DRIVER_NUMBER, - /** - * An enum member indicating that [FleetPromptCode] 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) { - NO_PROMPT -> Value.NO_PROMPT - VEHICLE_NUMBER -> Value.VEHICLE_NUMBER - DRIVER_NUMBER -> Value.DRIVER_NUMBER - 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) { - NO_PROMPT -> Known.NO_PROMPT - VEHICLE_NUMBER -> Known.VEHICLE_NUMBER - DRIVER_NUMBER -> Known.DRIVER_NUMBER - else -> throw LithicInvalidDataException("Unknown FleetPromptCode: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): FleetPromptCode = 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 FleetPromptCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Code indicating which restrictions, if any, there are on purchase. This is configured at - * a program level and is a static configuration, and does not change on a request to - * request basis - */ - class FleetRestrictionCode - @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 NO_RESTRICTIONS = of("NO_RESTRICTIONS") - - @JvmField val FUEL_ONLY = of("FUEL_ONLY") - - @JvmStatic fun of(value: String) = FleetRestrictionCode(JsonField.of(value)) - } - - /** An enum containing [FleetRestrictionCode]'s known values. */ - enum class Known { - NO_RESTRICTIONS, - FUEL_ONLY, - } - - /** - * An enum containing [FleetRestrictionCode]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [FleetRestrictionCode] 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 { - NO_RESTRICTIONS, - FUEL_ONLY, - /** - * An enum member indicating that [FleetRestrictionCode] 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) { - NO_RESTRICTIONS -> Value.NO_RESTRICTIONS - FUEL_ONLY -> Value.FUEL_ONLY - 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) { - NO_RESTRICTIONS -> Known.NO_RESTRICTIONS - FUEL_ONLY -> Known.FUEL_ONLY - else -> throw LithicInvalidDataException("Unknown FleetRestrictionCode: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): FleetRestrictionCode = 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 FleetRestrictionCode && 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 AsaRequestFleetInfo && - fleetPromptCode == other.fleetPromptCode && - fleetRestrictionCode == other.fleetRestrictionCode && - driverNumber == other.driverNumber && - vehicleNumber == other.vehicleNumber && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - fleetPromptCode, - fleetRestrictionCode, - driverNumber, - vehicleNumber, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaRequestFleetInfo{fleetPromptCode=$fleetPromptCode, fleetRestrictionCode=$fleetRestrictionCode, driverNumber=$driverNumber, vehicleNumber=$vehicleNumber, additionalProperties=$additionalProperties}" - } - - /** The latest Authorization Challenge that was issued to the cardholder for this merchant. */ - class LatestChallenge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val phoneNumber: JsonField, - private val status: JsonField, - private val completedAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("phone_number") - @ExcludeMissing - phoneNumber: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("completed_at") - @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - ) : this(phoneNumber, status, completedAt, mutableMapOf()) - - /** - * The phone number used for sending Authorization Challenge SMS. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun phoneNumber(): String = phoneNumber.getRequired("phone_number") - - /** - * The status of the Authorization Challenge - * * `COMPLETED` - Challenge was successfully completed by the cardholder - * * `PENDING` - Challenge is still open - * * `EXPIRED` - Challenge has expired without being completed - * * `ERROR` - There was an error processing the challenge - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * The date and time when the Authorization Challenge was completed in UTC. Present only if - * the status is `COMPLETED`. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun completedAt(): Optional = completedAt.getOptional("completed_at") - - /** - * Returns the raw JSON value of [phoneNumber]. - * - * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("phone_number") - @ExcludeMissing - fun _phoneNumber(): JsonField = phoneNumber - - /** - * 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 [completedAt]. - * - * Unlike [completedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("completed_at") - @ExcludeMissing - fun _completedAt(): JsonField = completedAt - - @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 [LatestChallenge]. - * - * The following fields are required: - * ```java - * .phoneNumber() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LatestChallenge]. */ - class Builder internal constructor() { - - private var phoneNumber: JsonField? = null - private var status: JsonField? = null - private var completedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(latestChallenge: LatestChallenge) = apply { - phoneNumber = latestChallenge.phoneNumber - status = latestChallenge.status - completedAt = latestChallenge.completedAt - additionalProperties = latestChallenge.additionalProperties.toMutableMap() - } - - /** The phone number used for sending Authorization Challenge SMS. */ - fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) - - /** - * Sets [Builder.phoneNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.phoneNumber] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun phoneNumber(phoneNumber: JsonField) = apply { - this.phoneNumber = phoneNumber - } - - /** - * The status of the Authorization Challenge - * * `COMPLETED` - Challenge was successfully completed by the cardholder - * * `PENDING` - Challenge is still open - * * `EXPIRED` - Challenge has expired without being completed - * * `ERROR` - There was an error processing the challenge - */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** - * The date and time when the Authorization Challenge was completed in UTC. Present only - * if the status is `COMPLETED`. - */ - fun completedAt(completedAt: OffsetDateTime) = completedAt(JsonField.of(completedAt)) - - /** - * Sets [Builder.completedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.completedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun completedAt(completedAt: JsonField) = apply { - this.completedAt = completedAt - } - - 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 [LatestChallenge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .phoneNumber() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): LatestChallenge = - LatestChallenge( - checkRequired("phoneNumber", phoneNumber), - checkRequired("status", status), - completedAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): LatestChallenge = apply { - if (validated) { - return@apply - } - - phoneNumber() - status().validate() - completedAt() - 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 (phoneNumber.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) - - /** - * The status of the Authorization Challenge - * * `COMPLETED` - Challenge was successfully completed by the cardholder - * * `PENDING` - Challenge is still open - * * `EXPIRED` - Challenge has expired without being completed - * * `ERROR` - There was an error processing the challenge - */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val PENDING = of("PENDING") - - @JvmField val EXPIRED = of("EXPIRED") - - @JvmField val ERROR = of("ERROR") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - COMPLETED, - PENDING, - EXPIRED, - ERROR, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMPLETED, - PENDING, - EXPIRED, - ERROR, - /** - * An enum member indicating that [Status] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMPLETED -> Value.COMPLETED - PENDING -> Value.PENDING - EXPIRED -> Value.EXPIRED - ERROR -> Value.ERROR - 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) { - COMPLETED -> Known.COMPLETED - PENDING -> Known.PENDING - EXPIRED -> Known.EXPIRED - ERROR -> Known.ERROR - else -> throw LithicInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && 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 LatestChallenge && - phoneNumber == other.phoneNumber && - status == other.status && - completedAt == other.completedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(phoneNumber, status, completedAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LatestChallenge{phoneNumber=$phoneNumber, status=$status, completedAt=$completedAt, additionalProperties=$additionalProperties}" - } - - /** Card network of the authorization. */ - class Network @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 AMEX = of("AMEX") - - @JvmField val INTERLINK = of("INTERLINK") - - @JvmField val MAESTRO = of("MAESTRO") - - @JvmField val MASTERCARD = of("MASTERCARD") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmField val VISA = of("VISA") - - @JvmStatic fun of(value: String) = Network(JsonField.of(value)) - } - - /** An enum containing [Network]'s known values. */ - enum class Known { - AMEX, - INTERLINK, - MAESTRO, - MASTERCARD, - UNKNOWN, - VISA, - } - - /** - * An enum containing [Network]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Network] 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 { - AMEX, - INTERLINK, - MAESTRO, - MASTERCARD, - UNKNOWN, - VISA, - /** An enum member indicating that [Network] 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) { - AMEX -> Value.AMEX - INTERLINK -> Value.INTERLINK - MAESTRO -> Value.MAESTRO - MASTERCARD -> Value.MASTERCARD - UNKNOWN -> Value.UNKNOWN - VISA -> Value.VISA - 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) { - AMEX -> Known.AMEX - INTERLINK -> Known.INTERLINK - MAESTRO -> Known.MAESTRO - MASTERCARD -> Known.MASTERCARD - UNKNOWN -> Known.UNKNOWN - VISA -> Known.VISA - else -> throw LithicInvalidDataException("Unknown Network: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Network = 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 Network && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Contains raw data provided by the card network, including attributes that provide further - * context about the authorization. If populated by the network, data is organized by Lithic and - * passed through without further modification. Please consult the official network - * documentation for more details about these values and how to use them. This object is only - * available to certain programs- contact your Customer Success Manager to discuss enabling - * access. - */ - class AsaNetworkSpecificData - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val mastercard: JsonField, - private val visa: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("mastercard") - @ExcludeMissing - mastercard: JsonField = JsonMissing.of(), - @JsonProperty("visa") - @ExcludeMissing - visa: JsonField = JsonMissing.of(), - ) : this(mastercard, visa, mutableMapOf()) - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun mastercard(): Optional = - mastercard.getOptional("mastercard") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun visa(): Optional = visa.getOptional("visa") - - /** - * Returns the raw JSON value of [mastercard]. - * - * Unlike [mastercard], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("mastercard") - @ExcludeMissing - fun _mastercard(): JsonField = mastercard - - /** - * Returns the raw JSON value of [visa]. - * - * Unlike [visa], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("visa") - @ExcludeMissing - fun _visa(): JsonField = visa - - @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 [AsaNetworkSpecificData]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaNetworkSpecificData]. */ - class Builder internal constructor() { - - private var mastercard: JsonField = JsonMissing.of() - private var visa: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(asaNetworkSpecificData: AsaNetworkSpecificData) = apply { - mastercard = asaNetworkSpecificData.mastercard - visa = asaNetworkSpecificData.visa - additionalProperties = asaNetworkSpecificData.additionalProperties.toMutableMap() - } - - fun mastercard(mastercard: AsaNetworkSpecificDataMastercard?) = - mastercard(JsonField.ofNullable(mastercard)) - - /** Alias for calling [Builder.mastercard] with `mastercard.orElse(null)`. */ - fun mastercard(mastercard: Optional) = - mastercard(mastercard.getOrNull()) - - /** - * Sets [Builder.mastercard] to an arbitrary JSON value. - * - * You should usually call [Builder.mastercard] with a well-typed - * [AsaNetworkSpecificDataMastercard] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun mastercard(mastercard: JsonField) = apply { - this.mastercard = mastercard - } - - fun visa(visa: AsaNetworkSpecificDataVisa?) = visa(JsonField.ofNullable(visa)) - - /** Alias for calling [Builder.visa] with `visa.orElse(null)`. */ - fun visa(visa: Optional) = visa(visa.getOrNull()) - - /** - * Sets [Builder.visa] to an arbitrary JSON value. - * - * You should usually call [Builder.visa] with a well-typed [AsaNetworkSpecificDataVisa] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun visa(visa: JsonField) = apply { this.visa = visa } - - 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 [AsaNetworkSpecificData]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AsaNetworkSpecificData = - AsaNetworkSpecificData(mastercard, visa, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaNetworkSpecificData = apply { - if (validated) { - return@apply - } - - mastercard().ifPresent { it.validate() } - visa().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (mastercard.asKnown().getOrNull()?.validity() ?: 0) + - (visa.asKnown().getOrNull()?.validity() ?: 0) - - class AsaNetworkSpecificDataMastercard - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val ecommerceSecurityLevelIndicator: JsonField, - private val onBehalfServiceResult: JsonField>, - private val transactionTypeIdentifier: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("ecommerce_security_level_indicator") - @ExcludeMissing - ecommerceSecurityLevelIndicator: JsonField = JsonMissing.of(), - @JsonProperty("on_behalf_service_result") - @ExcludeMissing - onBehalfServiceResult: JsonField> = JsonMissing.of(), - @JsonProperty("transaction_type_identifier") - @ExcludeMissing - transactionTypeIdentifier: JsonField = JsonMissing.of(), - ) : this( - ecommerceSecurityLevelIndicator, - onBehalfServiceResult, - transactionTypeIdentifier, - mutableMapOf(), - ) - - /** - * Indicates the electronic commerce security level and UCAF collection. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun ecommerceSecurityLevelIndicator(): Optional = - ecommerceSecurityLevelIndicator.getOptional("ecommerce_security_level_indicator") - - /** - * The On-behalf Service performed on the transaction and the results. Contains all - * applicable, on-behalf service results that were performed on a given transaction. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun onBehalfServiceResult(): Optional> = - onBehalfServiceResult.getOptional("on_behalf_service_result") - - /** - * Indicates the type of additional transaction purpose. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun transactionTypeIdentifier(): Optional = - transactionTypeIdentifier.getOptional("transaction_type_identifier") - - /** - * Returns the raw JSON value of [ecommerceSecurityLevelIndicator]. - * - * Unlike [ecommerceSecurityLevelIndicator], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("ecommerce_security_level_indicator") - @ExcludeMissing - fun _ecommerceSecurityLevelIndicator(): JsonField = - ecommerceSecurityLevelIndicator - - /** - * Returns the raw JSON value of [onBehalfServiceResult]. - * - * Unlike [onBehalfServiceResult], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_behalf_service_result") - @ExcludeMissing - fun _onBehalfServiceResult(): JsonField> = - onBehalfServiceResult - - /** - * Returns the raw JSON value of [transactionTypeIdentifier]. - * - * Unlike [transactionTypeIdentifier], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("transaction_type_identifier") - @ExcludeMissing - fun _transactionTypeIdentifier(): JsonField = transactionTypeIdentifier - - @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 - * [AsaNetworkSpecificDataMastercard]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaNetworkSpecificDataMastercard]. */ - class Builder internal constructor() { - - private var ecommerceSecurityLevelIndicator: JsonField = JsonMissing.of() - private var onBehalfServiceResult: JsonField>? = - null - private var transactionTypeIdentifier: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - asaNetworkSpecificDataMastercard: AsaNetworkSpecificDataMastercard - ) = apply { - ecommerceSecurityLevelIndicator = - asaNetworkSpecificDataMastercard.ecommerceSecurityLevelIndicator - onBehalfServiceResult = - asaNetworkSpecificDataMastercard.onBehalfServiceResult.map { - it.toMutableList() - } - transactionTypeIdentifier = - asaNetworkSpecificDataMastercard.transactionTypeIdentifier - additionalProperties = - asaNetworkSpecificDataMastercard.additionalProperties.toMutableMap() - } - - /** Indicates the electronic commerce security level and UCAF collection. */ - fun ecommerceSecurityLevelIndicator(ecommerceSecurityLevelIndicator: String?) = - ecommerceSecurityLevelIndicator( - JsonField.ofNullable(ecommerceSecurityLevelIndicator) - ) - - /** - * Alias for calling [Builder.ecommerceSecurityLevelIndicator] with - * `ecommerceSecurityLevelIndicator.orElse(null)`. - */ - fun ecommerceSecurityLevelIndicator( - ecommerceSecurityLevelIndicator: Optional - ) = ecommerceSecurityLevelIndicator(ecommerceSecurityLevelIndicator.getOrNull()) - - /** - * Sets [Builder.ecommerceSecurityLevelIndicator] to an arbitrary JSON value. - * - * You should usually call [Builder.ecommerceSecurityLevelIndicator] with a - * well-typed [String] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun ecommerceSecurityLevelIndicator( - ecommerceSecurityLevelIndicator: JsonField - ) = apply { this.ecommerceSecurityLevelIndicator = ecommerceSecurityLevelIndicator } - - /** - * The On-behalf Service performed on the transaction and the results. Contains all - * applicable, on-behalf service results that were performed on a given transaction. - */ - fun onBehalfServiceResult(onBehalfServiceResult: List?) = - onBehalfServiceResult(JsonField.ofNullable(onBehalfServiceResult)) - - /** - * Alias for calling [Builder.onBehalfServiceResult] with - * `onBehalfServiceResult.orElse(null)`. - */ - fun onBehalfServiceResult( - onBehalfServiceResult: Optional> - ) = onBehalfServiceResult(onBehalfServiceResult.getOrNull()) - - /** - * Sets [Builder.onBehalfServiceResult] to an arbitrary JSON value. - * - * You should usually call [Builder.onBehalfServiceResult] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun onBehalfServiceResult( - onBehalfServiceResult: JsonField> - ) = apply { - this.onBehalfServiceResult = onBehalfServiceResult.map { it.toMutableList() } - } - - /** - * Adds a single [OnBehalfServiceResult] to [Builder.onBehalfServiceResult]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOnBehalfServiceResult(onBehalfServiceResult: OnBehalfServiceResult) = apply { - this.onBehalfServiceResult = - (this.onBehalfServiceResult ?: JsonField.of(mutableListOf())).also { - checkKnown("onBehalfServiceResult", it).add(onBehalfServiceResult) - } - } - - /** Indicates the type of additional transaction purpose. */ - fun transactionTypeIdentifier(transactionTypeIdentifier: String?) = - transactionTypeIdentifier(JsonField.ofNullable(transactionTypeIdentifier)) - - /** - * Alias for calling [Builder.transactionTypeIdentifier] with - * `transactionTypeIdentifier.orElse(null)`. - */ - fun transactionTypeIdentifier(transactionTypeIdentifier: Optional) = - transactionTypeIdentifier(transactionTypeIdentifier.getOrNull()) - - /** - * Sets [Builder.transactionTypeIdentifier] to an arbitrary JSON value. - * - * You should usually call [Builder.transactionTypeIdentifier] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun transactionTypeIdentifier(transactionTypeIdentifier: JsonField) = - apply { - this.transactionTypeIdentifier = transactionTypeIdentifier - } - - 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 [AsaNetworkSpecificDataMastercard]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AsaNetworkSpecificDataMastercard = - AsaNetworkSpecificDataMastercard( - ecommerceSecurityLevelIndicator, - (onBehalfServiceResult ?: JsonMissing.of()).map { it.toImmutable() }, - transactionTypeIdentifier, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaNetworkSpecificDataMastercard = apply { - if (validated) { - return@apply - } - - ecommerceSecurityLevelIndicator() - onBehalfServiceResult().ifPresent { it.forEach { it.validate() } } - transactionTypeIdentifier() - 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 (ecommerceSecurityLevelIndicator.asKnown().isPresent) 1 else 0) + - (onBehalfServiceResult.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (transactionTypeIdentifier.asKnown().isPresent) 1 else 0) - - class OnBehalfServiceResult - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val result1: JsonField, - private val result2: JsonField, - private val service: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("result_1") - @ExcludeMissing - result1: JsonField = JsonMissing.of(), - @JsonProperty("result_2") - @ExcludeMissing - result2: JsonField = JsonMissing.of(), - @JsonProperty("service") - @ExcludeMissing - service: JsonField = JsonMissing.of(), - ) : this(result1, result2, service, mutableMapOf()) - - /** - * Indicates the results of the service processing. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun result1(): String = result1.getRequired("result_1") - - /** - * Identifies the results of the service processing. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun result2(): String = result2.getRequired("result_2") - - /** - * Indicates the service performed on 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 service(): String = service.getRequired("service") - - /** - * Returns the raw JSON value of [result1]. - * - * Unlike [result1], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("result_1") - @ExcludeMissing - fun _result1(): JsonField = result1 - - /** - * Returns the raw JSON value of [result2]. - * - * Unlike [result2], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("result_2") - @ExcludeMissing - fun _result2(): JsonField = result2 - - /** - * Returns the raw JSON value of [service]. - * - * Unlike [service], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("service") @ExcludeMissing fun _service(): JsonField = service - - @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 - * [OnBehalfServiceResult]. - * - * The following fields are required: - * ```java - * .result1() - * .result2() - * .service() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnBehalfServiceResult]. */ - class Builder internal constructor() { - - private var result1: JsonField? = null - private var result2: JsonField? = null - private var service: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(onBehalfServiceResult: OnBehalfServiceResult) = apply { - result1 = onBehalfServiceResult.result1 - result2 = onBehalfServiceResult.result2 - service = onBehalfServiceResult.service - additionalProperties = - onBehalfServiceResult.additionalProperties.toMutableMap() - } - - /** Indicates the results of the service processing. */ - fun result1(result1: String) = result1(JsonField.of(result1)) - - /** - * Sets [Builder.result1] to an arbitrary JSON value. - * - * You should usually call [Builder.result1] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun result1(result1: JsonField) = apply { this.result1 = result1 } - - /** Identifies the results of the service processing. */ - fun result2(result2: String) = result2(JsonField.of(result2)) - - /** - * Sets [Builder.result2] to an arbitrary JSON value. - * - * You should usually call [Builder.result2] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun result2(result2: JsonField) = apply { this.result2 = result2 } - - /** Indicates the service performed on the transaction. */ - fun service(service: String) = service(JsonField.of(service)) - - /** - * Sets [Builder.service] to an arbitrary JSON value. - * - * You should usually call [Builder.service] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun service(service: JsonField) = apply { this.service = service } - - 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 [OnBehalfServiceResult]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .result1() - * .result2() - * .service() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): OnBehalfServiceResult = - OnBehalfServiceResult( - checkRequired("result1", result1), - checkRequired("result2", result2), - checkRequired("service", service), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): OnBehalfServiceResult = apply { - if (validated) { - return@apply - } - - result1() - result2() - service() - 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 (result1.asKnown().isPresent) 1 else 0) + - (if (result2.asKnown().isPresent) 1 else 0) + - (if (service.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnBehalfServiceResult && - result1 == other.result1 && - result2 == other.result2 && - service == other.service && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(result1, result2, service, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnBehalfServiceResult{result1=$result1, result2=$result2, service=$service, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AsaNetworkSpecificDataMastercard && - ecommerceSecurityLevelIndicator == other.ecommerceSecurityLevelIndicator && - onBehalfServiceResult == other.onBehalfServiceResult && - transactionTypeIdentifier == other.transactionTypeIdentifier && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - ecommerceSecurityLevelIndicator, - onBehalfServiceResult, - transactionTypeIdentifier, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaNetworkSpecificDataMastercard{ecommerceSecurityLevelIndicator=$ecommerceSecurityLevelIndicator, onBehalfServiceResult=$onBehalfServiceResult, transactionTypeIdentifier=$transactionTypeIdentifier, additionalProperties=$additionalProperties}" - } - - class AsaNetworkSpecificDataVisa - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val businessApplicationIdentifier: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("business_application_identifier") - @ExcludeMissing - businessApplicationIdentifier: JsonField = JsonMissing.of() - ) : this(businessApplicationIdentifier, mutableMapOf()) - - /** - * Identifies the purpose or category of a transaction, used to classify and process - * transactions according to Visa’s rules. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun businessApplicationIdentifier(): Optional = - businessApplicationIdentifier.getOptional("business_application_identifier") - - /** - * Returns the raw JSON value of [businessApplicationIdentifier]. - * - * Unlike [businessApplicationIdentifier], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("business_application_identifier") - @ExcludeMissing - fun _businessApplicationIdentifier(): JsonField = businessApplicationIdentifier - - @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 - * [AsaNetworkSpecificDataVisa]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaNetworkSpecificDataVisa]. */ - class Builder internal constructor() { - - private var businessApplicationIdentifier: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(asaNetworkSpecificDataVisa: AsaNetworkSpecificDataVisa) = apply { - businessApplicationIdentifier = - asaNetworkSpecificDataVisa.businessApplicationIdentifier - additionalProperties = - asaNetworkSpecificDataVisa.additionalProperties.toMutableMap() - } - - /** - * Identifies the purpose or category of a transaction, used to classify and process - * transactions according to Visa’s rules. - */ - fun businessApplicationIdentifier(businessApplicationIdentifier: String?) = - businessApplicationIdentifier( - JsonField.ofNullable(businessApplicationIdentifier) - ) - - /** - * Alias for calling [Builder.businessApplicationIdentifier] with - * `businessApplicationIdentifier.orElse(null)`. - */ - fun businessApplicationIdentifier(businessApplicationIdentifier: Optional) = - businessApplicationIdentifier(businessApplicationIdentifier.getOrNull()) - - /** - * Sets [Builder.businessApplicationIdentifier] to an arbitrary JSON value. - * - * You should usually call [Builder.businessApplicationIdentifier] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun businessApplicationIdentifier( - businessApplicationIdentifier: JsonField - ) = apply { this.businessApplicationIdentifier = businessApplicationIdentifier } - - 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 [AsaNetworkSpecificDataVisa]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AsaNetworkSpecificDataVisa = - AsaNetworkSpecificDataVisa( - businessApplicationIdentifier, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaNetworkSpecificDataVisa = apply { - if (validated) { - return@apply - } - - businessApplicationIdentifier() - 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 (businessApplicationIdentifier.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AsaNetworkSpecificDataVisa && - businessApplicationIdentifier == other.businessApplicationIdentifier && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(businessApplicationIdentifier, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaNetworkSpecificDataVisa{businessApplicationIdentifier=$businessApplicationIdentifier, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AsaNetworkSpecificData && - mastercard == other.mastercard && - visa == other.visa && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(mastercard, visa, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaNetworkSpecificData{mastercard=$mastercard, visa=$visa, additionalProperties=$additionalProperties}" - } - - class Pos - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val entryMode: JsonField, - private val terminal: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("entry_mode") - @ExcludeMissing - entryMode: JsonField = JsonMissing.of(), - @JsonProperty("terminal") - @ExcludeMissing - terminal: JsonField = JsonMissing.of(), - ) : this(entryMode, terminal, mutableMapOf()) - - /** - * POS > Entry Mode object in ASA - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun entryMode(): Optional = entryMode.getOptional("entry_mode") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun terminal(): Optional = terminal.getOptional("terminal") - - /** - * Returns the raw JSON value of [entryMode]. - * - * Unlike [entryMode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_mode") - @ExcludeMissing - fun _entryMode(): JsonField = entryMode - - /** - * Returns the raw JSON value of [terminal]. - * - * Unlike [terminal], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("terminal") - @ExcludeMissing - fun _terminal(): JsonField = terminal - - @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 [Pos]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Pos]. */ - class Builder internal constructor() { - - private var entryMode: JsonField = JsonMissing.of() - private var terminal: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pos: Pos) = apply { - entryMode = pos.entryMode - terminal = pos.terminal - additionalProperties = pos.additionalProperties.toMutableMap() - } - - /** POS > Entry Mode object in ASA */ - fun entryMode(entryMode: AsaRequestPosEntryMode) = entryMode(JsonField.of(entryMode)) - - /** - * Sets [Builder.entryMode] to an arbitrary JSON value. - * - * You should usually call [Builder.entryMode] with a well-typed - * [AsaRequestPosEntryMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun entryMode(entryMode: JsonField) = apply { - this.entryMode = entryMode - } - - fun terminal(terminal: AsaPosTerminal) = terminal(JsonField.of(terminal)) - - /** - * Sets [Builder.terminal] to an arbitrary JSON value. - * - * You should usually call [Builder.terminal] with a well-typed [AsaPosTerminal] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun terminal(terminal: JsonField) = apply { this.terminal = terminal } - - 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 [Pos]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Pos = Pos(entryMode, terminal, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Pos = apply { - if (validated) { - return@apply - } - - entryMode().ifPresent { it.validate() } - terminal().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (entryMode.asKnown().getOrNull()?.validity() ?: 0) + - (terminal.asKnown().getOrNull()?.validity() ?: 0) - - /** POS > Entry Mode object in ASA */ - class AsaRequestPosEntryMode - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val card: JsonField, - private val cardholder: JsonField, - private val pan: JsonField, - private val pinEntered: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("card") @ExcludeMissing card: JsonField = JsonMissing.of(), - @JsonProperty("cardholder") - @ExcludeMissing - cardholder: JsonField = JsonMissing.of(), - @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), - @JsonProperty("pin_entered") - @ExcludeMissing - pinEntered: JsonField = JsonMissing.of(), - ) : this(card, cardholder, pan, pinEntered, mutableMapOf()) - - /** - * Card Presence Indicator - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun card(): Optional = card.getOptional("card") - - /** - * Cardholder Presence Indicator - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun cardholder(): Optional = cardholder.getOptional("cardholder") - - /** - * Method of entry for the PAN - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pan(): Optional = pan.getOptional("pan") - - /** - * Indicates whether the cardholder entered the PIN. True if the PIN was entered. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pinEntered(): Optional = pinEntered.getOptional("pin_entered") - - /** - * Returns the raw JSON value of [card]. - * - * Unlike [card], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card") @ExcludeMissing fun _card(): JsonField = card - - /** - * Returns the raw JSON value of [cardholder]. - * - * Unlike [cardholder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cardholder") - @ExcludeMissing - fun _cardholder(): JsonField = cardholder - - /** - * Returns the raw JSON value of [pan]. - * - * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan - - /** - * Returns the raw JSON value of [pinEntered]. - * - * Unlike [pinEntered], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pin_entered") - @ExcludeMissing - fun _pinEntered(): JsonField = pinEntered - - @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 - * [AsaRequestPosEntryMode]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaRequestPosEntryMode]. */ - class Builder internal constructor() { - - private var card: JsonField = JsonMissing.of() - private var cardholder: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() - private var pinEntered: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(asaRequestPosEntryMode: AsaRequestPosEntryMode) = apply { - card = asaRequestPosEntryMode.card - cardholder = asaRequestPosEntryMode.cardholder - pan = asaRequestPosEntryMode.pan - pinEntered = asaRequestPosEntryMode.pinEntered - additionalProperties = - asaRequestPosEntryMode.additionalProperties.toMutableMap() - } - - /** Card Presence Indicator */ - fun card(card: Card) = card(JsonField.of(card)) - - /** - * Sets [Builder.card] to an arbitrary JSON value. - * - * You should usually call [Builder.card] with a well-typed [Card] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun card(card: JsonField) = apply { this.card = card } - - /** Cardholder Presence Indicator */ - fun cardholder(cardholder: Cardholder) = cardholder(JsonField.of(cardholder)) - - /** - * Sets [Builder.cardholder] to an arbitrary JSON value. - * - * You should usually call [Builder.cardholder] with a well-typed [Cardholder] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun cardholder(cardholder: JsonField) = apply { - this.cardholder = cardholder - } - - /** Method of entry for the PAN */ - fun pan(pan: Pan) = pan(JsonField.of(pan)) - - /** - * Sets [Builder.pan] to an arbitrary JSON value. - * - * You should usually call [Builder.pan] with a well-typed [Pan] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun pan(pan: JsonField) = apply { this.pan = pan } - - /** - * Indicates whether the cardholder entered the PIN. True if the PIN was entered. - */ - fun pinEntered(pinEntered: Boolean) = pinEntered(JsonField.of(pinEntered)) - - /** - * Sets [Builder.pinEntered] to an arbitrary JSON value. - * - * You should usually call [Builder.pinEntered] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun pinEntered(pinEntered: JsonField) = apply { - this.pinEntered = pinEntered - } - - 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 [AsaRequestPosEntryMode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AsaRequestPosEntryMode = - AsaRequestPosEntryMode( - card, - cardholder, - pan, - pinEntered, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaRequestPosEntryMode = apply { - if (validated) { - return@apply - } - - card().ifPresent { it.validate() } - cardholder().ifPresent { it.validate() } - pan().ifPresent { it.validate() } - pinEntered() - 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 = - (card.asKnown().getOrNull()?.validity() ?: 0) + - (cardholder.asKnown().getOrNull()?.validity() ?: 0) + - (pan.asKnown().getOrNull()?.validity() ?: 0) + - (if (pinEntered.asKnown().isPresent) 1 else 0) - - /** Card Presence Indicator */ - class Card @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 PRESENT = of("PRESENT") - - @JvmField val NOT_PRESENT = of("NOT_PRESENT") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Card(JsonField.of(value)) - } - - /** An enum containing [Card]'s known values. */ - enum class Known { - PRESENT, - NOT_PRESENT, - UNKNOWN, - } - - /** - * An enum containing [Card]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Card] 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 { - PRESENT, - NOT_PRESENT, - UNKNOWN, - /** - * An enum member indicating that [Card] 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) { - PRESENT -> Value.PRESENT - NOT_PRESENT -> Value.NOT_PRESENT - UNKNOWN -> Value.UNKNOWN - 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) { - PRESENT -> Known.PRESENT - NOT_PRESENT -> Known.NOT_PRESENT - UNKNOWN -> Known.UNKNOWN - else -> throw LithicInvalidDataException("Unknown Card: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Card = 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 Card && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Cardholder Presence Indicator */ - class Cardholder - @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 DEFERRED_BILLING = of("DEFERRED_BILLING") - - @JvmField val ELECTRONIC_ORDER = of("ELECTRONIC_ORDER") - - @JvmField val INSTALLMENT = of("INSTALLMENT") - - @JvmField val MAIL_ORDER = of("MAIL_ORDER") - - @JvmField val NOT_PRESENT = of("NOT_PRESENT") - - @JvmField val PRESENT = of("PRESENT") - - @JvmField val REOCCURRING = of("REOCCURRING") - - @JvmField val TELEPHONE_ORDER = of("TELEPHONE_ORDER") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Cardholder(JsonField.of(value)) - } - - /** An enum containing [Cardholder]'s known values. */ - enum class Known { - DEFERRED_BILLING, - ELECTRONIC_ORDER, - INSTALLMENT, - MAIL_ORDER, - NOT_PRESENT, - PRESENT, - REOCCURRING, - TELEPHONE_ORDER, - UNKNOWN, - } - - /** - * An enum containing [Cardholder]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cardholder] 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 { - DEFERRED_BILLING, - ELECTRONIC_ORDER, - INSTALLMENT, - MAIL_ORDER, - NOT_PRESENT, - PRESENT, - REOCCURRING, - TELEPHONE_ORDER, - UNKNOWN, - /** - * An enum member indicating that [Cardholder] 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) { - DEFERRED_BILLING -> Value.DEFERRED_BILLING - ELECTRONIC_ORDER -> Value.ELECTRONIC_ORDER - INSTALLMENT -> Value.INSTALLMENT - MAIL_ORDER -> Value.MAIL_ORDER - NOT_PRESENT -> Value.NOT_PRESENT - PRESENT -> Value.PRESENT - REOCCURRING -> Value.REOCCURRING - TELEPHONE_ORDER -> Value.TELEPHONE_ORDER - UNKNOWN -> Value.UNKNOWN - 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) { - DEFERRED_BILLING -> Known.DEFERRED_BILLING - ELECTRONIC_ORDER -> Known.ELECTRONIC_ORDER - INSTALLMENT -> Known.INSTALLMENT - MAIL_ORDER -> Known.MAIL_ORDER - NOT_PRESENT -> Known.NOT_PRESENT - PRESENT -> Known.PRESENT - REOCCURRING -> Known.REOCCURRING - TELEPHONE_ORDER -> Known.TELEPHONE_ORDER - UNKNOWN -> Known.UNKNOWN - else -> throw LithicInvalidDataException("Unknown Cardholder: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Cardholder = 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 Cardholder && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Method of entry for the PAN */ - class Pan @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 AUTO_ENTRY = of("AUTO_ENTRY") - - @JvmField val BAR_CODE = of("BAR_CODE") - - @JvmField val CONTACTLESS = of("CONTACTLESS") - - @JvmField val ECOMMERCE = of("ECOMMERCE") - - @JvmField val ERROR_KEYED = of("ERROR_KEYED") - - @JvmField val ERROR_MAGNETIC_STRIPE = of("ERROR_MAGNETIC_STRIPE") - - @JvmField val ICC = of("ICC") - - @JvmField val KEY_ENTERED = of("KEY_ENTERED") - - @JvmField val MAGNETIC_STRIPE = of("MAGNETIC_STRIPE") - - @JvmField val MANUAL = of("MANUAL") - - @JvmField val OCR = of("OCR") - - @JvmField val SECURE_CARDLESS = of("SECURE_CARDLESS") - - @JvmField val UNSPECIFIED = of("UNSPECIFIED") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmField val CREDENTIAL_ON_FILE = of("CREDENTIAL_ON_FILE") - - @JvmStatic fun of(value: String) = Pan(JsonField.of(value)) - } - - /** An enum containing [Pan]'s known values. */ - enum class Known { - AUTO_ENTRY, - BAR_CODE, - CONTACTLESS, - ECOMMERCE, - ERROR_KEYED, - ERROR_MAGNETIC_STRIPE, - ICC, - KEY_ENTERED, - MAGNETIC_STRIPE, - MANUAL, - OCR, - SECURE_CARDLESS, - UNSPECIFIED, - UNKNOWN, - CREDENTIAL_ON_FILE, - } - - /** - * An enum containing [Pan]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Pan] 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 { - AUTO_ENTRY, - BAR_CODE, - CONTACTLESS, - ECOMMERCE, - ERROR_KEYED, - ERROR_MAGNETIC_STRIPE, - ICC, - KEY_ENTERED, - MAGNETIC_STRIPE, - MANUAL, - OCR, - SECURE_CARDLESS, - UNSPECIFIED, - UNKNOWN, - CREDENTIAL_ON_FILE, - /** - * An enum member indicating that [Pan] 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) { - AUTO_ENTRY -> Value.AUTO_ENTRY - BAR_CODE -> Value.BAR_CODE - CONTACTLESS -> Value.CONTACTLESS - ECOMMERCE -> Value.ECOMMERCE - ERROR_KEYED -> Value.ERROR_KEYED - ERROR_MAGNETIC_STRIPE -> Value.ERROR_MAGNETIC_STRIPE - ICC -> Value.ICC - KEY_ENTERED -> Value.KEY_ENTERED - MAGNETIC_STRIPE -> Value.MAGNETIC_STRIPE - MANUAL -> Value.MANUAL - OCR -> Value.OCR - SECURE_CARDLESS -> Value.SECURE_CARDLESS - UNSPECIFIED -> Value.UNSPECIFIED - UNKNOWN -> Value.UNKNOWN - CREDENTIAL_ON_FILE -> Value.CREDENTIAL_ON_FILE - 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) { - AUTO_ENTRY -> Known.AUTO_ENTRY - BAR_CODE -> Known.BAR_CODE - CONTACTLESS -> Known.CONTACTLESS - ECOMMERCE -> Known.ECOMMERCE - ERROR_KEYED -> Known.ERROR_KEYED - ERROR_MAGNETIC_STRIPE -> Known.ERROR_MAGNETIC_STRIPE - ICC -> Known.ICC - KEY_ENTERED -> Known.KEY_ENTERED - MAGNETIC_STRIPE -> Known.MAGNETIC_STRIPE - MANUAL -> Known.MANUAL - OCR -> Known.OCR - SECURE_CARDLESS -> Known.SECURE_CARDLESS - UNSPECIFIED -> Known.UNSPECIFIED - UNKNOWN -> Known.UNKNOWN - CREDENTIAL_ON_FILE -> Known.CREDENTIAL_ON_FILE - else -> throw LithicInvalidDataException("Unknown Pan: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Pan = 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 Pan && 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 AsaRequestPosEntryMode && - card == other.card && - cardholder == other.cardholder && - pan == other.pan && - pinEntered == other.pinEntered && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(card, cardholder, pan, pinEntered, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaRequestPosEntryMode{card=$card, cardholder=$cardholder, pan=$pan, pinEntered=$pinEntered, additionalProperties=$additionalProperties}" - } - - class AsaPosTerminal - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val attended: JsonField, - private val cardRetentionCapable: JsonField, - private val onPremise: JsonField, - private val operator: JsonField, - private val partialApprovalCapable: JsonField, - private val pinCapability: JsonField, - private val type: JsonField, - private val acceptorTerminalId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("attended") - @ExcludeMissing - attended: JsonField = JsonMissing.of(), - @JsonProperty("card_retention_capable") - @ExcludeMissing - cardRetentionCapable: JsonField = JsonMissing.of(), - @JsonProperty("on_premise") - @ExcludeMissing - onPremise: JsonField = JsonMissing.of(), - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("partial_approval_capable") - @ExcludeMissing - partialApprovalCapable: JsonField = JsonMissing.of(), - @JsonProperty("pin_capability") - @ExcludeMissing - pinCapability: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("acceptor_terminal_id") - @ExcludeMissing - acceptorTerminalId: JsonField = JsonMissing.of(), - ) : this( - attended, - cardRetentionCapable, - onPremise, - operator, - partialApprovalCapable, - pinCapability, - type, - acceptorTerminalId, - mutableMapOf(), - ) - - /** - * True if a clerk is present at the sale. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun attended(): Boolean = attended.getRequired("attended") - - /** - * True if the terminal is capable of retaining the card. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cardRetentionCapable(): Boolean = - cardRetentionCapable.getRequired("card_retention_capable") - - /** - * True if the sale was made at the place of business (vs. mobile). - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun onPremise(): Boolean = onPremise.getRequired("on_premise") - - /** - * The person that is designated to swipe the card - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * True if the terminal is capable of partial approval. Partial approval is when part of - * a transaction is approved and another payment must be used for the remainder. Example - * scenario: A $40 transaction is attempted on a prepaid card with a $25 balance. If - * partial approval is enabled, $25 can be authorized, at which point the POS will - * prompt the user for an additional payment of $15. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun partialApprovalCapable(): Boolean = - partialApprovalCapable.getRequired("partial_approval_capable") - - /** - * Status of whether the POS is able to accept PINs - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun pinCapability(): PinCapability = pinCapability.getRequired("pin_capability") - - /** - * POS 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 type(): Type = type.getRequired("type") - - /** - * Uniquely identifies a terminal at the card acceptor location of acquiring - * institutions or merchant POS Systems. Left justified with trailing spaces. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun acceptorTerminalId(): Optional = - acceptorTerminalId.getOptional("acceptor_terminal_id") - - /** - * Returns the raw JSON value of [attended]. - * - * Unlike [attended], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attended") @ExcludeMissing fun _attended(): JsonField = attended - - /** - * Returns the raw JSON value of [cardRetentionCapable]. - * - * Unlike [cardRetentionCapable], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("card_retention_capable") - @ExcludeMissing - fun _cardRetentionCapable(): JsonField = cardRetentionCapable - - /** - * Returns the raw JSON value of [onPremise]. - * - * Unlike [onPremise], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("on_premise") - @ExcludeMissing - fun _onPremise(): JsonField = onPremise - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("operator") - @ExcludeMissing - fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [partialApprovalCapable]. - * - * Unlike [partialApprovalCapable], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("partial_approval_capable") - @ExcludeMissing - fun _partialApprovalCapable(): JsonField = partialApprovalCapable - - /** - * Returns the raw JSON value of [pinCapability]. - * - * Unlike [pinCapability], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pin_capability") - @ExcludeMissing - fun _pinCapability(): JsonField = pinCapability - - /** - * 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 [acceptorTerminalId]. - * - * Unlike [acceptorTerminalId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("acceptor_terminal_id") - @ExcludeMissing - fun _acceptorTerminalId(): JsonField = acceptorTerminalId - - @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 [AsaPosTerminal]. - * - * The following fields are required: - * ```java - * .attended() - * .cardRetentionCapable() - * .onPremise() - * .operator() - * .partialApprovalCapable() - * .pinCapability() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AsaPosTerminal]. */ - class Builder internal constructor() { - - private var attended: JsonField? = null - private var cardRetentionCapable: JsonField? = null - private var onPremise: JsonField? = null - private var operator: JsonField? = null - private var partialApprovalCapable: JsonField? = null - private var pinCapability: JsonField? = null - private var type: JsonField? = null - private var acceptorTerminalId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(asaPosTerminal: AsaPosTerminal) = apply { - attended = asaPosTerminal.attended - cardRetentionCapable = asaPosTerminal.cardRetentionCapable - onPremise = asaPosTerminal.onPremise - operator = asaPosTerminal.operator - partialApprovalCapable = asaPosTerminal.partialApprovalCapable - pinCapability = asaPosTerminal.pinCapability - type = asaPosTerminal.type - acceptorTerminalId = asaPosTerminal.acceptorTerminalId - additionalProperties = asaPosTerminal.additionalProperties.toMutableMap() - } - - /** True if a clerk is present at the sale. */ - fun attended(attended: Boolean) = attended(JsonField.of(attended)) - - /** - * Sets [Builder.attended] to an arbitrary JSON value. - * - * You should usually call [Builder.attended] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attended(attended: JsonField) = apply { this.attended = attended } - - /** True if the terminal is capable of retaining the card. */ - fun cardRetentionCapable(cardRetentionCapable: Boolean) = - cardRetentionCapable(JsonField.of(cardRetentionCapable)) - - /** - * Sets [Builder.cardRetentionCapable] to an arbitrary JSON value. - * - * You should usually call [Builder.cardRetentionCapable] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun cardRetentionCapable(cardRetentionCapable: JsonField) = apply { - this.cardRetentionCapable = cardRetentionCapable - } - - /** True if the sale was made at the place of business (vs. mobile). */ - fun onPremise(onPremise: Boolean) = onPremise(JsonField.of(onPremise)) - - /** - * Sets [Builder.onPremise] to an arbitrary JSON value. - * - * You should usually call [Builder.onPremise] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun onPremise(onPremise: JsonField) = apply { this.onPremise = onPremise } - - /** The person that is designated to swipe the card */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** - * True if the terminal is capable of partial approval. Partial approval is when - * part of a transaction is approved and another payment must be used for the - * remainder. Example scenario: A $40 transaction is attempted on a prepaid card - * with a $25 balance. If partial approval is enabled, $25 can be authorized, at - * which point the POS will prompt the user for an additional payment of $15. - */ - fun partialApprovalCapable(partialApprovalCapable: Boolean) = - partialApprovalCapable(JsonField.of(partialApprovalCapable)) - - /** - * Sets [Builder.partialApprovalCapable] to an arbitrary JSON value. - * - * You should usually call [Builder.partialApprovalCapable] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun partialApprovalCapable(partialApprovalCapable: JsonField) = apply { - this.partialApprovalCapable = partialApprovalCapable - } - - /** Status of whether the POS is able to accept PINs */ - fun pinCapability(pinCapability: PinCapability) = - pinCapability(JsonField.of(pinCapability)) - - /** - * Sets [Builder.pinCapability] to an arbitrary JSON value. - * - * You should usually call [Builder.pinCapability] with a well-typed [PinCapability] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun pinCapability(pinCapability: JsonField) = apply { - this.pinCapability = pinCapability - } - - /** POS 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 [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 } - - /** - * Uniquely identifies a terminal at the card acceptor location of acquiring - * institutions or merchant POS Systems. Left justified with trailing spaces. - */ - fun acceptorTerminalId(acceptorTerminalId: String?) = - acceptorTerminalId(JsonField.ofNullable(acceptorTerminalId)) - - /** - * Alias for calling [Builder.acceptorTerminalId] with - * `acceptorTerminalId.orElse(null)`. - */ - fun acceptorTerminalId(acceptorTerminalId: Optional) = - acceptorTerminalId(acceptorTerminalId.getOrNull()) - - /** - * Sets [Builder.acceptorTerminalId] to an arbitrary JSON value. - * - * You should usually call [Builder.acceptorTerminalId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun acceptorTerminalId(acceptorTerminalId: JsonField) = apply { - this.acceptorTerminalId = acceptorTerminalId - } - - 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 [AsaPosTerminal]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .attended() - * .cardRetentionCapable() - * .onPremise() - * .operator() - * .partialApprovalCapable() - * .pinCapability() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AsaPosTerminal = - AsaPosTerminal( - checkRequired("attended", attended), - checkRequired("cardRetentionCapable", cardRetentionCapable), - checkRequired("onPremise", onPremise), - checkRequired("operator", operator), - checkRequired("partialApprovalCapable", partialApprovalCapable), - checkRequired("pinCapability", pinCapability), - checkRequired("type", type), - acceptorTerminalId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): AsaPosTerminal = apply { - if (validated) { - return@apply - } - - attended() - cardRetentionCapable() - onPremise() - operator().validate() - partialApprovalCapable() - pinCapability().validate() - type().validate() - acceptorTerminalId() - 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 (attended.asKnown().isPresent) 1 else 0) + - (if (cardRetentionCapable.asKnown().isPresent) 1 else 0) + - (if (onPremise.asKnown().isPresent) 1 else 0) + - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (if (partialApprovalCapable.asKnown().isPresent) 1 else 0) + - (pinCapability.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (acceptorTerminalId.asKnown().isPresent) 1 else 0) - - /** The person that is designated to swipe the card */ - class Operator @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 ADMINISTRATIVE = of("ADMINISTRATIVE") - - @JvmField val CARDHOLDER = of("CARDHOLDER") - - @JvmField val CARD_ACCEPTOR = of("CARD_ACCEPTOR") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - ADMINISTRATIVE, - CARDHOLDER, - CARD_ACCEPTOR, - UNKNOWN, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] 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 { - ADMINISTRATIVE, - CARDHOLDER, - CARD_ACCEPTOR, - UNKNOWN, - /** - * An enum member indicating that [Operator] 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) { - ADMINISTRATIVE -> Value.ADMINISTRATIVE - CARDHOLDER -> Value.CARDHOLDER - CARD_ACCEPTOR -> Value.CARD_ACCEPTOR - UNKNOWN -> Value.UNKNOWN - 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) { - ADMINISTRATIVE -> Known.ADMINISTRATIVE - CARDHOLDER -> Known.CARDHOLDER - CARD_ACCEPTOR -> Known.CARD_ACCEPTOR - UNKNOWN -> Known.UNKNOWN - else -> throw LithicInvalidDataException("Unknown Operator: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): Operator = 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 Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Status of whether the POS is able to accept PINs */ - class PinCapability - @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 CAPABLE = of("CAPABLE") - - @JvmField val INOPERATIVE = of("INOPERATIVE") - - @JvmField val NOT_CAPABLE = of("NOT_CAPABLE") - - @JvmField val UNSPECIFIED = of("UNSPECIFIED") - - @JvmStatic fun of(value: String) = PinCapability(JsonField.of(value)) - } - - /** An enum containing [PinCapability]'s known values. */ - enum class Known { - CAPABLE, - INOPERATIVE, - NOT_CAPABLE, - UNSPECIFIED, - } - - /** - * An enum containing [PinCapability]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [PinCapability] 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 { - CAPABLE, - INOPERATIVE, - NOT_CAPABLE, - UNSPECIFIED, - /** - * An enum member indicating that [PinCapability] 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) { - CAPABLE -> Value.CAPABLE - INOPERATIVE -> Value.INOPERATIVE - NOT_CAPABLE -> Value.NOT_CAPABLE - UNSPECIFIED -> Value.UNSPECIFIED - 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) { - CAPABLE -> Known.CAPABLE - INOPERATIVE -> Known.INOPERATIVE - NOT_CAPABLE -> Known.NOT_CAPABLE - UNSPECIFIED -> Known.UNSPECIFIED - else -> throw LithicInvalidDataException("Unknown PinCapability: $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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): PinCapability = 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 PinCapability && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** POS Type */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ADMINISTRATIVE = of("ADMINISTRATIVE") - - @JvmField val ATM = of("ATM") - - @JvmField val AUTHORIZATION = of("AUTHORIZATION") - - @JvmField val COUPON_MACHINE = of("COUPON_MACHINE") - - @JvmField val DIAL_TERMINAL = of("DIAL_TERMINAL") - - @JvmField val ECOMMERCE = of("ECOMMERCE") - - @JvmField val ECR = of("ECR") - - @JvmField val FUEL_MACHINE = of("FUEL_MACHINE") - - @JvmField val HOME_TERMINAL = of("HOME_TERMINAL") - - @JvmField val MICR = of("MICR") - - @JvmField val OFF_PREMISE = of("OFF_PREMISE") - - @JvmField val PAYMENT = of("PAYMENT") - - @JvmField val PDA = of("PDA") - - @JvmField val PHONE = of("PHONE") - - @JvmField val POINT = of("POINT") - - @JvmField val POS_TERMINAL = of("POS_TERMINAL") - - @JvmField val PUBLIC_UTILITY = of("PUBLIC_UTILITY") - - @JvmField val SELF_SERVICE = of("SELF_SERVICE") - - @JvmField val TELEVISION = of("TELEVISION") - - @JvmField val TELLER = of("TELLER") - - @JvmField val TRAVELERS_CHECK_MACHINE = of("TRAVELERS_CHECK_MACHINE") - - @JvmField val VENDING = of("VENDING") - - @JvmField val VOICE = of("VOICE") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ADMINISTRATIVE, - ATM, - AUTHORIZATION, - COUPON_MACHINE, - DIAL_TERMINAL, - ECOMMERCE, - ECR, - FUEL_MACHINE, - HOME_TERMINAL, - MICR, - OFF_PREMISE, - PAYMENT, - PDA, - PHONE, - POINT, - POS_TERMINAL, - PUBLIC_UTILITY, - SELF_SERVICE, - TELEVISION, - TELLER, - TRAVELERS_CHECK_MACHINE, - VENDING, - VOICE, - UNKNOWN, - } - - /** - * 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 { - ADMINISTRATIVE, - ATM, - AUTHORIZATION, - COUPON_MACHINE, - DIAL_TERMINAL, - ECOMMERCE, - ECR, - FUEL_MACHINE, - HOME_TERMINAL, - MICR, - OFF_PREMISE, - PAYMENT, - PDA, - PHONE, - POINT, - POS_TERMINAL, - PUBLIC_UTILITY, - SELF_SERVICE, - TELEVISION, - TELLER, - TRAVELERS_CHECK_MACHINE, - VENDING, - VOICE, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADMINISTRATIVE -> Value.ADMINISTRATIVE - ATM -> Value.ATM - AUTHORIZATION -> Value.AUTHORIZATION - COUPON_MACHINE -> Value.COUPON_MACHINE - DIAL_TERMINAL -> Value.DIAL_TERMINAL - ECOMMERCE -> Value.ECOMMERCE - ECR -> Value.ECR - FUEL_MACHINE -> Value.FUEL_MACHINE - HOME_TERMINAL -> Value.HOME_TERMINAL - MICR -> Value.MICR - OFF_PREMISE -> Value.OFF_PREMISE - PAYMENT -> Value.PAYMENT - PDA -> Value.PDA - PHONE -> Value.PHONE - POINT -> Value.POINT - POS_TERMINAL -> Value.POS_TERMINAL - PUBLIC_UTILITY -> Value.PUBLIC_UTILITY - SELF_SERVICE -> Value.SELF_SERVICE - TELEVISION -> Value.TELEVISION - TELLER -> Value.TELLER - TRAVELERS_CHECK_MACHINE -> Value.TRAVELERS_CHECK_MACHINE - VENDING -> Value.VENDING - VOICE -> Value.VOICE - UNKNOWN -> Value.UNKNOWN - 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) { - ADMINISTRATIVE -> Known.ADMINISTRATIVE - ATM -> Known.ATM - AUTHORIZATION -> Known.AUTHORIZATION - COUPON_MACHINE -> Known.COUPON_MACHINE - DIAL_TERMINAL -> Known.DIAL_TERMINAL - ECOMMERCE -> Known.ECOMMERCE - ECR -> Known.ECR - FUEL_MACHINE -> Known.FUEL_MACHINE - HOME_TERMINAL -> Known.HOME_TERMINAL - MICR -> Known.MICR - OFF_PREMISE -> Known.OFF_PREMISE - PAYMENT -> Known.PAYMENT - PDA -> Known.PDA - PHONE -> Known.PHONE - POINT -> Known.POINT - POS_TERMINAL -> Known.POS_TERMINAL - PUBLIC_UTILITY -> Known.PUBLIC_UTILITY - SELF_SERVICE -> Known.SELF_SERVICE - TELEVISION -> Known.TELEVISION - TELLER -> Known.TELLER - TRAVELERS_CHECK_MACHINE -> Known.TRAVELERS_CHECK_MACHINE - VENDING -> Known.VENDING - VOICE -> Known.VOICE - UNKNOWN -> Known.UNKNOWN - 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 - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LithicInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - 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 - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AsaPosTerminal && - attended == other.attended && - cardRetentionCapable == other.cardRetentionCapable && - onPremise == other.onPremise && - operator == other.operator && - partialApprovalCapable == other.partialApprovalCapable && - pinCapability == other.pinCapability && - type == other.type && - acceptorTerminalId == other.acceptorTerminalId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - attended, - cardRetentionCapable, - onPremise, - operator, - partialApprovalCapable, - pinCapability, - type, - acceptorTerminalId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AsaPosTerminal{attended=$attended, cardRetentionCapable=$cardRetentionCapable, onPremise=$onPremise, operator=$operator, partialApprovalCapable=$partialApprovalCapable, pinCapability=$pinCapability, type=$type, acceptorTerminalId=$acceptorTerminalId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Pos && - entryMode == other.entryMode && - terminal == other.terminal && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(entryMode, terminal, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Pos{entryMode=$entryMode, terminal=$terminal, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -9551,7 +1737,6 @@ private constructor( cardholderCurrency == other.cardholderCurrency && cashAmount == other.cashAmount && created == other.created && - eventType == other.eventType && merchant == other.merchant && merchantAmount == other.merchantAmount && merchantCurrency == other.merchantCurrency && @@ -9572,6 +1757,7 @@ private constructor( pos == other.pos && tokenInfo == other.tokenInfo && ttl == other.ttl && + eventType == other.eventType && additionalProperties == other.additionalProperties } @@ -9587,7 +1773,6 @@ private constructor( cardholderCurrency, cashAmount, created, - eventType, merchant, merchantAmount, merchantCurrency, @@ -9608,6 +1793,7 @@ private constructor( pos, tokenInfo, ttl, + eventType, additionalProperties, ) } @@ -9615,5 +1801,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CardAuthorizationApprovalRequestWebhookEvent{token=$token, acquirerFee=$acquirerFee, amount=$amount, amounts=$amounts, authorizationAmount=$authorizationAmount, avs=$avs, card=$card, cardholderCurrency=$cardholderCurrency, cashAmount=$cashAmount, created=$created, eventType=$eventType, merchant=$merchant, merchantAmount=$merchantAmount, merchantCurrency=$merchantCurrency, serviceLocation=$serviceLocation, settledAmount=$settledAmount, status=$status, transactionInitiator=$transactionInitiator, accountType=$accountType, cardholderAuthentication=$cardholderAuthentication, cashback=$cashback, conversionRate=$conversionRate, eventToken=$eventToken, fleetInfo=$fleetInfo, latestChallenge=$latestChallenge, network=$network, networkRiskScore=$networkRiskScore, networkSpecificData=$networkSpecificData, pos=$pos, tokenInfo=$tokenInfo, ttl=$ttl, additionalProperties=$additionalProperties}" + "CardAuthorizationApprovalRequestWebhookEvent{token=$token, acquirerFee=$acquirerFee, amount=$amount, amounts=$amounts, authorizationAmount=$authorizationAmount, avs=$avs, card=$card, cardholderCurrency=$cardholderCurrency, cashAmount=$cashAmount, created=$created, merchant=$merchant, merchantAmount=$merchantAmount, merchantCurrency=$merchantCurrency, serviceLocation=$serviceLocation, settledAmount=$settledAmount, status=$status, transactionInitiator=$transactionInitiator, accountType=$accountType, cardholderAuthentication=$cardholderAuthentication, cashback=$cashback, conversionRate=$conversionRate, eventToken=$eventToken, fleetInfo=$fleetInfo, latestChallenge=$latestChallenge, network=$network, networkRiskScore=$networkRiskScore, networkSpecificData=$networkSpecificData, pos=$pos, tokenInfo=$tokenInfo, ttl=$ttl, eventType=$eventType, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationChallengeResponseParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationChallengeResponseParams.kt new file mode 100644 index 00000000..15b907cd --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationChallengeResponseParams.kt @@ -0,0 +1,597 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.Params +import com.lithic.api.core.checkRequired +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Card program's response to Authorization Challenge. Programs that have Authorization Challenges + * configured as Out of Band receive a + * [card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge) + * webhook when an authorization attempt triggers a challenge. The card program should respond using + * this endpoint after the cardholder completes the challenge. + */ +class CardAuthorizationChallengeResponseParams +private constructor( + private val eventToken: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun eventToken(): Optional = Optional.ofNullable(eventToken) + + /** + * Whether the cardholder has approved or declined the issued challenge + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun response(): Response = body.response() + + /** + * Returns the raw JSON value of [response]. + * + * Unlike [response], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _response(): JsonField = body._response() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CardAuthorizationChallengeResponseParams]. + * + * The following fields are required: + * ```java + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardAuthorizationChallengeResponseParams]. */ + class Builder internal constructor() { + + private var eventToken: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + cardAuthorizationChallengeResponseParams: CardAuthorizationChallengeResponseParams + ) = apply { + eventToken = cardAuthorizationChallengeResponseParams.eventToken + body = cardAuthorizationChallengeResponseParams.body.toBuilder() + additionalHeaders = + cardAuthorizationChallengeResponseParams.additionalHeaders.toBuilder() + additionalQueryParams = + cardAuthorizationChallengeResponseParams.additionalQueryParams.toBuilder() + } + + fun eventToken(eventToken: String?) = apply { this.eventToken = eventToken } + + /** Alias for calling [Builder.eventToken] with `eventToken.orElse(null)`. */ + fun eventToken(eventToken: Optional) = eventToken(eventToken.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [response] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Whether the cardholder has approved or declined the issued challenge */ + fun response(response: Response) = apply { body.response(response) } + + /** + * Sets [Builder.response] to an arbitrary JSON value. + * + * You should usually call [Builder.response] with a well-typed [Response] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun response(response: JsonField) = apply { body.response(response) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardAuthorizationChallengeResponseParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardAuthorizationChallengeResponseParams = + CardAuthorizationChallengeResponseParams( + eventToken, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> eventToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Card program's response to Authorization Challenge */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val response: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("response") + @ExcludeMissing + response: JsonField = JsonMissing.of() + ) : this(response, mutableMapOf()) + + /** + * Whether the cardholder has approved or declined the issued challenge + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun response(): Response = response.getRequired("response") + + /** + * Returns the raw JSON value of [response]. + * + * Unlike [response], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("response") @ExcludeMissing fun _response(): JsonField = response + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var response: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + response = body.response + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Whether the cardholder has approved or declined the issued challenge */ + fun response(response: Response) = response(JsonField.of(response)) + + /** + * Sets [Builder.response] to an arbitrary JSON value. + * + * You should usually call [Builder.response] with a well-typed [Response] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun response(response: JsonField) = apply { this.response = response } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("response", response), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + response().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 = (response.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + response == other.response && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(response, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{response=$response, additionalProperties=$additionalProperties}" + } + + /** Whether the cardholder has approved or declined the issued challenge */ + class Response @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 APPROVE = of("APPROVE") + + @JvmField val DECLINE = of("DECLINE") + + @JvmStatic fun of(value: String) = Response(JsonField.of(value)) + } + + /** An enum containing [Response]'s known values. */ + enum class Known { + APPROVE, + DECLINE, + } + + /** + * An enum containing [Response]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Response] 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 { + APPROVE, + DECLINE, + /** An enum member indicating that [Response] 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) { + APPROVE -> Value.APPROVE + DECLINE -> Value.DECLINE + 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) { + APPROVE -> Known.APPROVE + DECLINE -> Known.DECLINE + else -> throw LithicInvalidDataException("Unknown Response: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Response = 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 Response && 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 CardAuthorizationChallengeResponseParams && + eventToken == other.eventToken && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(eventToken, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardAuthorizationChallengeResponseParams{eventToken=$eventToken, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationChallengeWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationChallengeWebhookEvent.kt new file mode 100644 index 00000000..b4e2e546 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardAuthorizationChallengeWebhookEvent.kt @@ -0,0 +1,680 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkRequired +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CardAuthorizationChallengeWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val authorization: JsonField, + private val challenge: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("authorization") + @ExcludeMissing + authorization: JsonField = JsonMissing.of(), + @JsonProperty("challenge") + @ExcludeMissing + challenge: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(authorization, challenge, eventType, mutableMapOf()) + + /** + * The authorization that triggered the challenge + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun authorization(): CardAuthorization = authorization.getRequired("authorization") + + /** + * Details of the Authorization Challenge issued during card authorization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun challenge(): AuthorizationChallenge = challenge.getRequired("challenge") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventType(): EventType = eventType.getRequired("event_type") + + /** + * Returns the raw JSON value of [authorization]. + * + * Unlike [authorization], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("authorization") + @ExcludeMissing + fun _authorization(): JsonField = authorization + + /** + * Returns the raw JSON value of [challenge]. + * + * Unlike [challenge], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("challenge") + @ExcludeMissing + fun _challenge(): JsonField = challenge + + /** + * Returns the raw JSON value of [eventType]. + * + * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType + + @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 + * [CardAuthorizationChallengeWebhookEvent]. + * + * The following fields are required: + * ```java + * .authorization() + * .challenge() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardAuthorizationChallengeWebhookEvent]. */ + class Builder internal constructor() { + + private var authorization: JsonField? = null + private var challenge: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cardAuthorizationChallengeWebhookEvent: CardAuthorizationChallengeWebhookEvent + ) = apply { + authorization = cardAuthorizationChallengeWebhookEvent.authorization + challenge = cardAuthorizationChallengeWebhookEvent.challenge + eventType = cardAuthorizationChallengeWebhookEvent.eventType + additionalProperties = + cardAuthorizationChallengeWebhookEvent.additionalProperties.toMutableMap() + } + + /** The authorization that triggered the challenge */ + fun authorization(authorization: CardAuthorization) = + authorization(JsonField.of(authorization)) + + /** + * Sets [Builder.authorization] to an arbitrary JSON value. + * + * You should usually call [Builder.authorization] with a well-typed [CardAuthorization] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun authorization(authorization: JsonField) = apply { + this.authorization = authorization + } + + /** Details of the Authorization Challenge issued during card authorization */ + fun challenge(challenge: AuthorizationChallenge) = challenge(JsonField.of(challenge)) + + /** + * Sets [Builder.challenge] to an arbitrary JSON value. + * + * You should usually call [Builder.challenge] with a well-typed [AuthorizationChallenge] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun challenge(challenge: JsonField) = apply { + this.challenge = challenge + } + + /** The type of event that occurred. */ + fun eventType(eventType: EventType) = eventType(JsonField.of(eventType)) + + /** + * Sets [Builder.eventType] to an arbitrary JSON value. + * + * You should usually call [Builder.eventType] with a well-typed [EventType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } + + 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 [CardAuthorizationChallengeWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .authorization() + * .challenge() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardAuthorizationChallengeWebhookEvent = + CardAuthorizationChallengeWebhookEvent( + checkRequired("authorization", authorization), + checkRequired("challenge", challenge), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CardAuthorizationChallengeWebhookEvent = apply { + if (validated) { + return@apply + } + + authorization().validate() + challenge().validate() + eventType().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 = + (authorization.asKnown().getOrNull()?.validity() ?: 0) + + (challenge.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** Details of the Authorization Challenge issued during card authorization */ + class AuthorizationChallenge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val eventToken: JsonField, + private val expiryTime: JsonField, + private val startTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event_token") + @ExcludeMissing + eventToken: JsonField = JsonMissing.of(), + @JsonProperty("expiry_time") + @ExcludeMissing + expiryTime: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + ) : this(eventToken, expiryTime, startTime, mutableMapOf()) + + /** + * Globally unique identifier for the event that triggered the challenge. Use this token + * when calling the challenge response endpoint + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventToken(): String = eventToken.getRequired("event_token") + + /** + * ISO-8601 time at which the challenge expires + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expiryTime(): OffsetDateTime = expiryTime.getRequired("expiry_time") + + /** + * ISO-8601 time at which the challenge was issued + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startTime(): OffsetDateTime = startTime.getRequired("start_time") + + /** + * Returns the raw JSON value of [eventToken]. + * + * Unlike [eventToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_token") + @ExcludeMissing + fun _eventToken(): JsonField = eventToken + + /** + * Returns the raw JSON value of [expiryTime]. + * + * Unlike [expiryTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry_time") + @ExcludeMissing + fun _expiryTime(): JsonField = expiryTime + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + @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 [AuthorizationChallenge]. + * + * The following fields are required: + * ```java + * .eventToken() + * .expiryTime() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthorizationChallenge]. */ + class Builder internal constructor() { + + private var eventToken: JsonField? = null + private var expiryTime: JsonField? = null + private var startTime: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authorizationChallenge: AuthorizationChallenge) = apply { + eventToken = authorizationChallenge.eventToken + expiryTime = authorizationChallenge.expiryTime + startTime = authorizationChallenge.startTime + additionalProperties = authorizationChallenge.additionalProperties.toMutableMap() + } + + /** + * Globally unique identifier for the event that triggered the challenge. Use this token + * when calling the challenge response endpoint + */ + fun eventToken(eventToken: String) = eventToken(JsonField.of(eventToken)) + + /** + * Sets [Builder.eventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.eventToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventToken(eventToken: JsonField) = apply { this.eventToken = eventToken } + + /** ISO-8601 time at which the challenge expires */ + fun expiryTime(expiryTime: OffsetDateTime) = expiryTime(JsonField.of(expiryTime)) + + /** + * Sets [Builder.expiryTime] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryTime(expiryTime: JsonField) = apply { + this.expiryTime = expiryTime + } + + /** ISO-8601 time at which the challenge was issued */ + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + 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 [AuthorizationChallenge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventToken() + * .expiryTime() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AuthorizationChallenge = + AuthorizationChallenge( + checkRequired("eventToken", eventToken), + checkRequired("expiryTime", expiryTime), + checkRequired("startTime", startTime), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AuthorizationChallenge = apply { + if (validated) { + return@apply + } + + eventToken() + expiryTime() + startTime() + 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 (eventToken.asKnown().isPresent) 1 else 0) + + (if (expiryTime.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthorizationChallenge && + eventToken == other.eventToken && + expiryTime == other.expiryTime && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(eventToken, expiryTime, startTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthorizationChallenge{eventToken=$eventToken, expiryTime=$expiryTime, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + /** The type of event that occurred. */ + class EventType @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_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_AUTHORIZATION_CHALLENGE + } + + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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_AUTHORIZATION_CHALLENGE, + /** + * An enum member indicating that [EventType] 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_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE + 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_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE + else -> throw LithicInvalidDataException("Unknown EventType: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EventType = 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 EventType && 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 CardAuthorizationChallengeWebhookEvent && + authorization == other.authorization && + challenge == other.challenge && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(authorization, challenge, eventType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardAuthorizationChallengeWebhookEvent{authorization=$authorization, challenge=$challenge, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt index 95bb0e4b..13ede67a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt @@ -406,9 +406,9 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of the - * cardholder. + * cardholder. Use an integer value. * * `RISK_SCORE`: Mastercard only: Assessment by the network of the authentication risk - * level, with a higher value indicating a higher amount of risk. + * level, with a higher value indicating a higher amount of risk. Use an integer value. * * `MESSAGE_CATEGORY`: The category of the authentication being processed. * * `ADDRESS_MATCH`: Lithic's evaluation result comparing transaction's address data with * the cardholder KYC data if it exists. Valid values are `MATCH`, `MATCH_ADDRESS_ONLY`, @@ -520,9 +520,10 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of - * the cardholder. + * the cardholder. Use an integer value. * * `RISK_SCORE`: Mastercard only: Assessment by the network of the authentication risk - * level, with a higher value indicating a higher amount of risk. + * level, with a higher value indicating a higher amount of risk. Use an integer + * value. * * `MESSAGE_CATEGORY`: The category of the authentication being processed. * * `ADDRESS_MATCH`: Lithic's evaluation result comparing transaction's address data * with the cardholder KYC data if it exists. Valid values are `MATCH`, @@ -568,8 +569,11 @@ private constructor( /** Alias for calling [value] with `ConditionalValue.ofRegex(regex)`. */ fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ - fun value(number: Long) = value(ConditionalValue.ofNumber(number)) + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ fun valueOfListOfStrings(listOfStrings: List) = @@ -677,9 +681,9 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of the - * cardholder. + * cardholder. Use an integer value. * * `RISK_SCORE`: Mastercard only: Assessment by the network of the authentication risk - * level, with a higher value indicating a higher amount of risk. + * level, with a higher value indicating a higher amount of risk. Use an integer value. * * `MESSAGE_CATEGORY`: The category of the authentication being processed. * * `ADDRESS_MATCH`: Lithic's evaluation result comparing transaction's address data with * the cardholder KYC data if it exists. Valid values are `MATCH`, `MATCH_ADDRESS_ONLY`, diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchActionParameters.kt index 1f29b9ce..7c5ed20d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchActionParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchActionParameters.kt @@ -1701,7 +1701,8 @@ private constructor( * * `COMPANY_ID`: The company ID (also known as Standard Entry Class (SEC) Company ID) of * the entity initiating the ACH transaction. * * `TIMESTAMP`: The timestamp of the ACH transaction in ISO 8601 format. - * * `TRANSACTION_AMOUNT`: The amount of the ACH transaction in minor units (cents). + * * `TRANSACTION_AMOUNT`: The amount of the ACH transaction in minor units (cents). Use an + * integer value. * * `SEC_CODE`: Standard Entry Class code indicating the type of ACH transaction. Valid * values include PPD (Prearranged Payment and Deposit Entry), CCD (Corporate Credit or * Debit Entry), WEB (Internet-Initiated/Mobile Entry), TEL (Telephone-Initiated Entry), @@ -1805,7 +1806,8 @@ private constructor( * * `COMPANY_ID`: The company ID (also known as Standard Entry Class (SEC) Company ID) * of the entity initiating the ACH transaction. * * `TIMESTAMP`: The timestamp of the ACH transaction in ISO 8601 format. - * * `TRANSACTION_AMOUNT`: The amount of the ACH transaction in minor units (cents). + * * `TRANSACTION_AMOUNT`: The amount of the ACH transaction in minor units (cents). Use + * an integer value. * * `SEC_CODE`: Standard Entry Class code indicating the type of ACH transaction. Valid * values include PPD (Prearranged Payment and Deposit Entry), CCD (Corporate Credit * or Debit Entry), WEB (Internet-Initiated/Mobile Entry), TEL (Telephone-Initiated @@ -1852,8 +1854,11 @@ private constructor( /** Alias for calling [value] with `ConditionalValue.ofRegex(regex)`. */ fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ - fun value(number: Long) = value(ConditionalValue.ofNumber(number)) + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ fun valueOfListOfStrings(listOfStrings: List) = @@ -1954,7 +1959,8 @@ private constructor( * * `COMPANY_ID`: The company ID (also known as Standard Entry Class (SEC) Company ID) of * the entity initiating the ACH transaction. * * `TIMESTAMP`: The timestamp of the ACH transaction in ISO 8601 format. - * * `TRANSACTION_AMOUNT`: The amount of the ACH transaction in minor units (cents). + * * `TRANSACTION_AMOUNT`: The amount of the ACH transaction in minor units (cents). Use an + * integer value. * * `SEC_CODE`: Standard Entry Class code indicating the type of ACH transaction. Valid * values include PPD (Prearranged Payment and Deposit Entry), CCD (Corporate Credit or * Debit Entry), WEB (Internet-Initiated/Mobile Entry), TEL (Telephone-Initiated Entry), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAuthorizationActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAuthorizationActionParameters.kt index a6f9f407..cdcbba7d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAuthorizationActionParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAuthorizationActionParameters.kt @@ -418,25 +418,26 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of the - * cardholder. + * cardholder. Use an integer value. * * `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This - * represents the amount of cash being withdrawn or advanced. + * represents the amount of cash being withdrawn or advanced. Use an integer value. * * `RISK_SCORE`: 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. + * range of 0-99, Lithic will normalize the score by multiplying the raw score by 10x. Use + * an integer value. * * `CARD_TRANSACTION_COUNT_15M`: The number of transactions on the card in the trailing 15 - * minutes before the authorization. + * minutes before the authorization. Use an integer value. * * `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the trailing - * hour up and until the authorization. + * hour up and until the authorization. Use an integer value. * * `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the trailing 24 - * hours up and until the authorization. + * hours up and until the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_15M`: The number of declined transactions on the card in the - * trailing 15 minutes before the authorization. + * trailing 15 minutes before the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_1H`: The number of declined transactions on the card in the - * trailing hour up and until the authorization. + * trailing hour up and until the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_24H`: The number of declined transactions on the card in the - * trailing 24 hours up and until the authorization. + * trailing 24 hours up and until the authorization. Use an integer value. * * `CARD_STATE`: The current state of the card associated with the transaction. Valid * values are `CLOSED`, `OPEN`, `PAUSED`, `PENDING_ACTIVATION`, `PENDING_FULFILLMENT`. * * `PIN_ENTERED`: Indicates whether a PIN was entered during the transaction. Valid values @@ -459,18 +460,20 @@ private constructor( * service, e.g. "10001". When a service location is present in the network data, the * service location postal code is used. Otherwise, falls back to the card acceptor postal * code. - * * `CARD_AGE`: The age of the card in seconds at the time of the authorization. + * * `CARD_AGE`: The age of the card in seconds at the time of the authorization. Use an + * integer value. * * `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time of the - * authorization. + * authorization. Use an integer value. * * `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the entity's * transaction history. Null if fewer than 30 approved transactions in the specified - * window. Requires `parameters.scope` and `parameters.interval`. + * window. Requires `parameters.scope` and `parameters.interval`. Use a decimal value. * * `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the entity over * the specified window, in cents. Requires `parameters.scope` and `parameters.interval`. + * Use a decimal value. * * `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction amounts for * the entity over the specified window, in cents. Null if fewer than 30 approved * transactions in the specified window. Requires `parameters.scope` and - * `parameters.interval`. + * `parameters.interval`. Use a decimal value. * * `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen in the * entity's transaction history. Valid values are `TRUE`, `FALSE`. Requires * `parameters.scope`. @@ -480,25 +483,27 @@ private constructor( * values are `TRUE`, `FALSE`. Requires `parameters.scope`. * * `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for the entity * over the last 30 days (rolling). Requires `parameters.scope`. Not supported for - * `BUSINESS_ACCOUNT` scope. + * `BUSINESS_ACCOUNT` scope. Use an integer value. * * `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved transaction - * for the entity. Requires `parameters.scope`. + * for the entity, rounded to the nearest whole day. Requires `parameters.scope`. Use an + * integer value. * * `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in the - * entity's transaction history. Requires `parameters.scope`. + * entity's transaction history. Requires `parameters.scope`. Use an integer value. * * `IS_NEW_MERCHANT`: Whether the card acceptor ID has not been seen in the card's * approved transaction history (capped at the 1000 most recently seen merchants). Valid * values are `TRUE`, `FALSE`. Card-scoped only; no `parameters` required. * * `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as a - * percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + * percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. Use a decimal + * value. * * `TRAVEL_SPEED`: The estimated speed of travel derived from the distance between the * postal code centers of the last card-present transaction and the current transaction, * divided by the elapsed time. Null if there is no prior card-present transaction, if * either postal code cannot be geocoded, or if elapsed time is zero. Requires - * `parameters.unit` set to `MPH` or `KPH`. + * `parameters.unit` set to `MPH` or `KPH`. Use a decimal value. * * `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal code * centers of the last card-present transaction and the current transaction. Null if there * is no prior card-present transaction or if either postal code cannot be geocoded. - * Requires `parameters.unit` set to `MILES` or `KILOMETERS`. + * Requires `parameters.unit` set to `MILES` or `KILOMETERS`. Use a decimal 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). @@ -638,26 +643,26 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of - * the cardholder. + * the cardholder. Use an integer value. * * `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This - * represents the amount of cash being withdrawn or advanced. + * represents the amount of cash being withdrawn or advanced. Use an integer value. * * `RISK_SCORE`: 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. + * by 10x. Use an integer value. * * `CARD_TRANSACTION_COUNT_15M`: The number of transactions on the card in the - * trailing 15 minutes before the authorization. + * trailing 15 minutes before the authorization. Use an integer value. * * `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the trailing - * hour up and until the authorization. + * hour up and until the authorization. Use an integer value. * * `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the - * trailing 24 hours up and until the authorization. + * trailing 24 hours up and until the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_15M`: The number of declined transactions on the card in the - * trailing 15 minutes before the authorization. + * trailing 15 minutes before the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_1H`: The number of declined transactions on the card in the - * trailing hour up and until the authorization. + * trailing hour up and until the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_24H`: The number of declined transactions on the card in the - * trailing 24 hours up and until the authorization. + * trailing 24 hours up and until the authorization. Use an integer value. * * `CARD_STATE`: The current state of the card associated with the transaction. Valid * values are `CLOSED`, `OPEN`, `PAUSED`, `PENDING_ACTIVATION`, `PENDING_FULFILLMENT`. * * `PIN_ENTERED`: Indicates whether a PIN was entered during the transaction. Valid @@ -680,19 +685,20 @@ private constructor( * service, e.g. "10001". When a service location is present in the network data, the * service location postal code is used. Otherwise, falls back to the card acceptor * postal code. - * * `CARD_AGE`: The age of the card in seconds at the time of the authorization. + * * `CARD_AGE`: The age of the card in seconds at the time of the authorization. Use an + * integer value. * * `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time of - * the authorization. + * the authorization. Use an integer value. * * `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the entity's * transaction history. Null if fewer than 30 approved transactions in the specified - * window. Requires `parameters.scope` and `parameters.interval`. + * window. Requires `parameters.scope` and `parameters.interval`. Use a decimal value. * * `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the entity * over the specified window, in cents. Requires `parameters.scope` and - * `parameters.interval`. + * `parameters.interval`. Use a decimal value. * * `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction amounts * for the entity over the specified window, in cents. Null if fewer than 30 approved * transactions in the specified window. Requires `parameters.scope` and - * `parameters.interval`. + * `parameters.interval`. Use a decimal value. * * `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen in * the entity's transaction history. Valid values are `TRUE`, `FALSE`. Requires * `parameters.scope`. @@ -702,25 +708,28 @@ private constructor( * values are `TRUE`, `FALSE`. Requires `parameters.scope`. * * `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for the * entity over the last 30 days (rolling). Requires `parameters.scope`. Not supported - * for `BUSINESS_ACCOUNT` scope. + * for `BUSINESS_ACCOUNT` scope. Use an integer value. * * `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved - * transaction for the entity. Requires `parameters.scope`. + * transaction for the entity, rounded to the nearest whole day. Requires + * `parameters.scope`. Use an integer value. * * `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in the - * entity's transaction history. Requires `parameters.scope`. + * entity's transaction history. Requires `parameters.scope`. Use an integer value. * * `IS_NEW_MERCHANT`: Whether the card acceptor ID has not been seen in the card's * approved transaction history (capped at the 1000 most recently seen merchants). * Valid values are `TRUE`, `FALSE`. Card-scoped only; no `parameters` required. * * `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as a - * percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + * percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. Use a + * decimal value. * * `TRAVEL_SPEED`: The estimated speed of travel derived from the distance between the * postal code centers of the last card-present transaction and the current * transaction, divided by the elapsed time. Null if there is no prior card-present * transaction, if either postal code cannot be geocoded, or if elapsed time is zero. - * Requires `parameters.unit` set to `MPH` or `KPH`. + * Requires `parameters.unit` set to `MPH` or `KPH`. Use a decimal value. * * `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal code * centers of the last card-present transaction and the current transaction. Null if * there is no prior card-present transaction or if either postal code cannot be - * geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. + * geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. Use a decimal + * value. */ fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) @@ -762,8 +771,11 @@ private constructor( /** Alias for calling [value] with `ConditionalValue.ofRegex(regex)`. */ fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ - fun value(number: Long) = value(ConditionalValue.ofNumber(number)) + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ fun valueOfListOfStrings(listOfStrings: List) = @@ -903,25 +915,26 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of the - * cardholder. + * cardholder. Use an integer value. * * `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This - * represents the amount of cash being withdrawn or advanced. + * represents the amount of cash being withdrawn or advanced. Use an integer value. * * `RISK_SCORE`: 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. + * range of 0-99, Lithic will normalize the score by multiplying the raw score by 10x. Use + * an integer value. * * `CARD_TRANSACTION_COUNT_15M`: The number of transactions on the card in the trailing 15 - * minutes before the authorization. + * minutes before the authorization. Use an integer value. * * `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the trailing - * hour up and until the authorization. + * hour up and until the authorization. Use an integer value. * * `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the trailing 24 - * hours up and until the authorization. + * hours up and until the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_15M`: The number of declined transactions on the card in the - * trailing 15 minutes before the authorization. + * trailing 15 minutes before the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_1H`: The number of declined transactions on the card in the - * trailing hour up and until the authorization. + * trailing hour up and until the authorization. Use an integer value. * * `CARD_DECLINE_COUNT_24H`: The number of declined transactions on the card in the - * trailing 24 hours up and until the authorization. + * trailing 24 hours up and until the authorization. Use an integer value. * * `CARD_STATE`: The current state of the card associated with the transaction. Valid * values are `CLOSED`, `OPEN`, `PAUSED`, `PENDING_ACTIVATION`, `PENDING_FULFILLMENT`. * * `PIN_ENTERED`: Indicates whether a PIN was entered during the transaction. Valid values @@ -944,18 +957,20 @@ private constructor( * service, e.g. "10001". When a service location is present in the network data, the * service location postal code is used. Otherwise, falls back to the card acceptor postal * code. - * * `CARD_AGE`: The age of the card in seconds at the time of the authorization. + * * `CARD_AGE`: The age of the card in seconds at the time of the authorization. Use an + * integer value. * * `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time of the - * authorization. + * authorization. Use an integer value. * * `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the entity's * transaction history. Null if fewer than 30 approved transactions in the specified - * window. Requires `parameters.scope` and `parameters.interval`. + * window. Requires `parameters.scope` and `parameters.interval`. Use a decimal value. * * `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the entity over * the specified window, in cents. Requires `parameters.scope` and `parameters.interval`. + * Use a decimal value. * * `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction amounts for * the entity over the specified window, in cents. Null if fewer than 30 approved * transactions in the specified window. Requires `parameters.scope` and - * `parameters.interval`. + * `parameters.interval`. Use a decimal value. * * `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen in the * entity's transaction history. Valid values are `TRUE`, `FALSE`. Requires * `parameters.scope`. @@ -965,25 +980,27 @@ private constructor( * values are `TRUE`, `FALSE`. Requires `parameters.scope`. * * `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for the entity * over the last 30 days (rolling). Requires `parameters.scope`. Not supported for - * `BUSINESS_ACCOUNT` scope. + * `BUSINESS_ACCOUNT` scope. Use an integer value. * * `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved transaction - * for the entity. Requires `parameters.scope`. + * for the entity, rounded to the nearest whole day. Requires `parameters.scope`. Use an + * integer value. * * `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in the - * entity's transaction history. Requires `parameters.scope`. + * entity's transaction history. Requires `parameters.scope`. Use an integer value. * * `IS_NEW_MERCHANT`: Whether the card acceptor ID has not been seen in the card's * approved transaction history (capped at the 1000 most recently seen merchants). Valid * values are `TRUE`, `FALSE`. Card-scoped only; no `parameters` required. * * `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as a - * percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + * percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. Use a decimal + * value. * * `TRAVEL_SPEED`: The estimated speed of travel derived from the distance between the * postal code centers of the last card-present transaction and the current transaction, * divided by the elapsed time. Null if there is no prior card-present transaction, if * either postal code cannot be geocoded, or if elapsed time is zero. Requires - * `parameters.unit` set to `MPH` or `KPH`. + * `parameters.unit` set to `MPH` or `KPH`. Use a decimal value. * * `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal code * centers of the last card-present transaction and the current transaction. Null if there * is no prior card-present transaction or if either postal code cannot be geocoded. - * Requires `parameters.unit` set to `MILES` or `KILOMETERS`. + * Requires `parameters.unit` set to `MILES` or `KILOMETERS`. Use a decimal value. */ class Attribute @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalCardTransactionUpdateActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalCardTransactionUpdateActionParameters.kt index 573d613d..2db669d0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalCardTransactionUpdateActionParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalCardTransactionUpdateActionParameters.kt @@ -285,11 +285,12 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of the - * cardholder. + * cardholder. Use an integer value. * * `RISK_SCORE`: 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. + * range of 0-99, Lithic will normalize the score by multiplying the raw score by 10x. Use + * an integer value. * * `TRANSACTION_STATUS`: The status of the transaction. Valid values are `PENDING`, * `VOIDED`, `SETTLING`, `SETTLED`, `BOUNCED`, `RETURNED`, `DECLINED`, `EXPIRED`. * * `LAST_EVENT_TYPE`: The type of the most recent event on the transaction. Valid values @@ -308,14 +309,16 @@ private constructor( * * `WALLET_TYPE`: For transactions using a digital wallet token, indicates the source of * the token. Valid values are `APPLE_PAY`, `GOOGLE_PAY`, `SAMSUNG_PAY`, `MASTERPASS`, * `MERCHANT`, `OTHER`, `NONE`. - * * `CARD_AGE`: The age of the card in seconds at the time of the transaction. - * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the transaction. + * * `CARD_AGE`: The age of the card in seconds at the time of the transaction. Use an + * integer value. + * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the transaction. Use an + * integer value. * * `SPEND_VELOCITY_COUNT`: The number of transactions matching the specified filters * within the given period. Requires `parameters` with `scope`, `period`, and optional - * `filters`. + * `filters`. Use an integer value. * * `SPEND_VELOCITY_AMOUNT`: The total spend amount (in cents) of transactions matching the * specified filters within the given period. Requires `parameters` with `scope`, - * `period`, and optional `filters`. + * `period`, and optional `filters`. Use an integer 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). @@ -443,12 +446,12 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of - * the cardholder. + * the cardholder. Use an integer value. * * `RISK_SCORE`: 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. + * by 10x. Use an integer value. * * `TRANSACTION_STATUS`: The status of the transaction. Valid values are `PENDING`, * `VOIDED`, `SETTLING`, `SETTLED`, `BOUNCED`, `RETURNED`, `DECLINED`, `EXPIRED`. * * `LAST_EVENT_TYPE`: The type of the most recent event on the transaction. Valid @@ -468,14 +471,16 @@ private constructor( * * `WALLET_TYPE`: For transactions using a digital wallet token, indicates the source * of the token. Valid values are `APPLE_PAY`, `GOOGLE_PAY`, `SAMSUNG_PAY`, * `MASTERPASS`, `MERCHANT`, `OTHER`, `NONE`. - * * `CARD_AGE`: The age of the card in seconds at the time of the transaction. + * * `CARD_AGE`: The age of the card in seconds at the time of the transaction. Use an + * integer value. * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the transaction. + * Use an integer value. * * `SPEND_VELOCITY_COUNT`: The number of transactions matching the specified filters * within the given period. Requires `parameters` with `scope`, `period`, and optional - * `filters`. + * `filters`. Use an integer value. * * `SPEND_VELOCITY_AMOUNT`: The total spend amount (in cents) of transactions matching * the specified filters within the given period. Requires `parameters` with `scope`, - * `period`, and optional `filters`. + * `period`, and optional `filters`. Use an integer value. */ fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) @@ -517,8 +522,11 @@ private constructor( /** Alias for calling [value] with `ConditionalValue.ofRegex(regex)`. */ fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ - fun value(number: Long) = value(ConditionalValue.ofNumber(number)) + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ fun valueOfListOfStrings(listOfStrings: List) = @@ -646,11 +654,12 @@ private constructor( * * `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer fee * field in the settlement/cardholder billing currency. This is the amount the issuer * should authorize against unless the issuer is paying the acquirer fee on behalf of the - * cardholder. + * cardholder. Use an integer value. * * `RISK_SCORE`: 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. + * range of 0-99, Lithic will normalize the score by multiplying the raw score by 10x. Use + * an integer value. * * `TRANSACTION_STATUS`: The status of the transaction. Valid values are `PENDING`, * `VOIDED`, `SETTLING`, `SETTLED`, `BOUNCED`, `RETURNED`, `DECLINED`, `EXPIRED`. * * `LAST_EVENT_TYPE`: The type of the most recent event on the transaction. Valid values @@ -669,14 +678,16 @@ private constructor( * * `WALLET_TYPE`: For transactions using a digital wallet token, indicates the source of * the token. Valid values are `APPLE_PAY`, `GOOGLE_PAY`, `SAMSUNG_PAY`, `MASTERPASS`, * `MERCHANT`, `OTHER`, `NONE`. - * * `CARD_AGE`: The age of the card in seconds at the time of the transaction. - * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the transaction. + * * `CARD_AGE`: The age of the card in seconds at the time of the transaction. Use an + * integer value. + * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the transaction. Use an + * integer value. * * `SPEND_VELOCITY_COUNT`: The number of transactions matching the specified filters * within the given period. Requires `parameters` with `scope`, `period`, and optional - * `filters`. + * `filters`. Use an integer value. * * `SPEND_VELOCITY_AMOUNT`: The total spend amount (in cents) of transactions matching the * specified filters within the given period. Requires `parameters` with `scope`, - * `period`, and optional `filters`. + * `period`, and optional `filters`. Use an integer value. */ class Attribute @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalTokenizationActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalTokenizationActionParameters.kt index 3894f58a..aba9b152 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalTokenizationActionParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalTokenizationActionParameters.kt @@ -1637,9 +1637,11 @@ private constructor( * `FACEBOOK`, `FITBIT_PAY`, `GARMIN_PAY`, `GOOGLE_PAY`, `GOOGLE_VCN`, `ISSUER_HCE`, * `MICROSOFT_PAY`, `NETFLIX`, `SAMSUNG_PAY`, `UNKNOWN`, `VISA_CHECKOUT`. * * `WALLET_ACCOUNT_SCORE`: Risk score for the account in the digital wallet. Numeric value - * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). + * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). Use an + * integer value. * * `WALLET_DEVICE_SCORE`: Risk score for the device in the digital wallet. Numeric value - * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). + * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). Use an + * integer value. * * `WALLET_RECOMMENDED_DECISION`: The decision recommended by the digital wallet provider. * Valid values include APPROVE, DECLINE, REQUIRE_ADDITIONAL_AUTHENTICATION. * * `WALLET_RECOMMENDATION_REASONS`: List of reasons provided by the digital wallet @@ -1769,10 +1771,10 @@ private constructor( * `VISA_CHECKOUT`. * * `WALLET_ACCOUNT_SCORE`: Risk score for the account in the digital wallet. Numeric * value where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium - * risk). + * risk). Use an integer value. * * `WALLET_DEVICE_SCORE`: Risk score for the device in the digital wallet. Numeric * value where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium - * risk). + * risk). Use an integer value. * * `WALLET_RECOMMENDED_DECISION`: The decision recommended by the digital wallet * provider. Valid values include APPROVE, DECLINE, REQUIRE_ADDITIONAL_AUTHENTICATION. * * `WALLET_RECOMMENDATION_REASONS`: List of reasons provided by the digital wallet @@ -1839,8 +1841,11 @@ private constructor( /** Alias for calling [value] with `ConditionalValue.ofRegex(regex)`. */ fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ - fun value(number: Long) = value(ConditionalValue.ofNumber(number)) + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ fun valueOfListOfStrings(listOfStrings: List) = @@ -1948,9 +1953,11 @@ private constructor( * `FACEBOOK`, `FITBIT_PAY`, `GARMIN_PAY`, `GOOGLE_PAY`, `GOOGLE_VCN`, `ISSUER_HCE`, * `MICROSOFT_PAY`, `NETFLIX`, `SAMSUNG_PAY`, `UNKNOWN`, `VISA_CHECKOUT`. * * `WALLET_ACCOUNT_SCORE`: Risk score for the account in the digital wallet. Numeric value - * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). + * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). Use an + * integer value. * * `WALLET_DEVICE_SCORE`: Risk score for the device in the digital wallet. Numeric value - * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). + * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). Use an + * integer value. * * `WALLET_RECOMMENDED_DECISION`: The decision recommended by the digital wallet provider. * Valid values include APPROVE, DECLINE, REQUIRE_ADDITIONAL_AUTHENTICATION. * * `WALLET_RECOMMENDATION_REASONS`: List of reasons provided by the digital wallet diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalValue.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalValue.kt index 00144363..2513b366 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalValue.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalValue.kt @@ -26,7 +26,8 @@ import java.util.Optional class ConditionalValue private constructor( private val regex: String? = null, - private val number: Long? = null, + private val integer: Long? = null, + private val number: Double? = null, private val listOfStrings: List? = null, private val timestamp: OffsetDateTime? = null, private val _json: JsonValue? = null, @@ -35,11 +36,9 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun regex(): Optional = Optional.ofNullable(regex) - /** - * A number, to be used with `IS_GREATER_THAN`, `IS_GREATER_THAN_OR_EQUAL_TO`, `IS_LESS_THAN`, - * `IS_LESS_THAN_OR_EQUAL_TO`, `IS_EQUAL_TO`, or `IS_NOT_EQUAL_TO` - */ - fun number(): Optional = Optional.ofNullable(number) + fun integer(): Optional = Optional.ofNullable(integer) + + fun number(): Optional = Optional.ofNullable(number) /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ fun listOfStrings(): Optional> = Optional.ofNullable(listOfStrings) @@ -49,6 +48,8 @@ private constructor( fun isRegex(): Boolean = regex != null + fun isInteger(): Boolean = integer != null + fun isNumber(): Boolean = number != null fun isListOfStrings(): Boolean = listOfStrings != null @@ -58,11 +59,9 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun asRegex(): String = regex.getOrThrow("regex") - /** - * A number, to be used with `IS_GREATER_THAN`, `IS_GREATER_THAN_OR_EQUAL_TO`, `IS_LESS_THAN`, - * `IS_LESS_THAN_OR_EQUAL_TO`, `IS_EQUAL_TO`, or `IS_NOT_EQUAL_TO` - */ - fun asNumber(): Long = number.getOrThrow("number") + fun asInteger(): Long = integer.getOrThrow("integer") + + fun asNumber(): Double = number.getOrThrow("number") /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ fun asListOfStrings(): List = listOfStrings.getOrThrow("listOfStrings") @@ -104,6 +103,7 @@ private constructor( fun accept(visitor: Visitor): T = when { regex != null -> visitor.visitRegex(regex) + integer != null -> visitor.visitInteger(integer) number != null -> visitor.visitNumber(number) listOfStrings != null -> visitor.visitListOfStrings(listOfStrings) timestamp != null -> visitor.visitTimestamp(timestamp) @@ -129,7 +129,9 @@ private constructor( object : Visitor { override fun visitRegex(regex: String) {} - override fun visitNumber(number: Long) {} + override fun visitInteger(integer: Long) {} + + override fun visitNumber(number: Double) {} override fun visitListOfStrings(listOfStrings: List) {} @@ -158,7 +160,9 @@ private constructor( object : Visitor { override fun visitRegex(regex: String) = 1 - override fun visitNumber(number: Long) = 1 + override fun visitInteger(integer: Long) = 1 + + override fun visitNumber(number: Double) = 1 override fun visitListOfStrings(listOfStrings: List) = listOfStrings.size @@ -175,16 +179,18 @@ private constructor( return other is ConditionalValue && regex == other.regex && + integer == other.integer && number == other.number && listOfStrings == other.listOfStrings && timestamp == other.timestamp } - override fun hashCode(): Int = Objects.hash(regex, number, listOfStrings, timestamp) + override fun hashCode(): Int = Objects.hash(regex, integer, number, listOfStrings, timestamp) override fun toString(): String = when { regex != null -> "ConditionalValue{regex=$regex}" + integer != null -> "ConditionalValue{integer=$integer}" number != null -> "ConditionalValue{number=$number}" listOfStrings != null -> "ConditionalValue{listOfStrings=$listOfStrings}" timestamp != null -> "ConditionalValue{timestamp=$timestamp}" @@ -197,11 +203,9 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ @JvmStatic fun ofRegex(regex: String) = ConditionalValue(regex = regex) - /** - * A number, to be used with `IS_GREATER_THAN`, `IS_GREATER_THAN_OR_EQUAL_TO`, - * `IS_LESS_THAN`, `IS_LESS_THAN_OR_EQUAL_TO`, `IS_EQUAL_TO`, or `IS_NOT_EQUAL_TO` - */ - @JvmStatic fun ofNumber(number: Long) = ConditionalValue(number = number) + @JvmStatic fun ofInteger(integer: Long) = ConditionalValue(integer = integer) + + @JvmStatic fun ofNumber(number: Double) = ConditionalValue(number = number) /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ @JvmStatic @@ -222,11 +226,9 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun visitRegex(regex: String): T - /** - * A number, to be used with `IS_GREATER_THAN`, `IS_GREATER_THAN_OR_EQUAL_TO`, - * `IS_LESS_THAN`, `IS_LESS_THAN_OR_EQUAL_TO`, `IS_EQUAL_TO`, or `IS_NOT_EQUAL_TO` - */ - fun visitNumber(number: Long): T + fun visitInteger(integer: Long): T + + fun visitNumber(number: Double): T /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ fun visitListOfStrings(listOfStrings: List): T @@ -263,6 +265,9 @@ private constructor( ConditionalValue(regex = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { + ConditionalValue(integer = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { ConditionalValue(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef>())?.let { @@ -293,6 +298,7 @@ private constructor( ) { when { value.regex != null -> generator.writeObject(value.regex) + value.integer != null -> generator.writeObject(value.integer) value.number != null -> generator.writeObject(value.number) value.listOfStrings != null -> generator.writeObject(value.listOfStrings) value.timestamp != null -> generator.writeObject(value.timestamp) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt index 703256af..902ebeb6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt @@ -72,6 +72,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during card + * authorization. The card program should issue its own challenge to the cardholder and then + * respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -270,6 +274,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during + * card authorization. The card program should issue its own challenge to the cardholder + * and then respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -465,6 +473,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during card + * authorization. The card program should issue its own challenge to the cardholder and then + * respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -572,6 +584,8 @@ private constructor( @JvmField val BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + @JvmField val CARD_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + @JvmField val CARD_AUTHORIZATION_CHALLENGE_RESPONSE = of("card_authorization.challenge_response") @@ -691,6 +705,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -756,6 +771,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -824,6 +840,7 @@ private constructor( BALANCE_UPDATED -> Value.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Value.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED @@ -897,6 +914,7 @@ private constructor( BALANCE_UPDATED -> Known.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Known.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt index 02ddc8b4..3b7b3a3b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt @@ -330,6 +330,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during card + * authorization. The card program should issue its own challenge to the cardholder and then + * respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -437,6 +441,8 @@ private constructor( @JvmField val BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + @JvmField val CARD_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + @JvmField val CARD_AUTHORIZATION_CHALLENGE_RESPONSE = of("card_authorization.challenge_response") @@ -556,6 +562,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -621,6 +628,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -689,6 +697,7 @@ private constructor( BALANCE_UPDATED -> Value.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Value.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED @@ -762,6 +771,7 @@ private constructor( BALANCE_UPDATED -> Known.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Known.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt index e4de107d..5ce64563 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt @@ -340,6 +340,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during card + * authorization. The card program should issue its own challenge to the cardholder and then + * respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -447,6 +451,8 @@ private constructor( @JvmField val BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + @JvmField val CARD_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + @JvmField val CARD_AUTHORIZATION_CHALLENGE_RESPONSE = of("card_authorization.challenge_response") @@ -566,6 +572,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -631,6 +638,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -699,6 +707,7 @@ private constructor( BALANCE_UPDATED -> Value.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Value.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED @@ -772,6 +781,7 @@ private constructor( BALANCE_UPDATED -> Known.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Known.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt index df9d4ecf..f8f639b0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt @@ -663,6 +663,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during card + * authorization. The card program should issue its own challenge to the cardholder and then + * respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -770,6 +774,8 @@ private constructor( @JvmField val BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + @JvmField val CARD_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + @JvmField val CARD_AUTHORIZATION_CHALLENGE_RESPONSE = of("card_authorization.challenge_response") @@ -889,6 +895,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -954,6 +961,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -1022,6 +1030,7 @@ private constructor( BALANCE_UPDATED -> Value.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Value.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED @@ -1095,6 +1104,7 @@ private constructor( BALANCE_UPDATED -> Known.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Known.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt index a66dc899..4556099a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt @@ -452,6 +452,8 @@ private constructor( @JvmField val BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + @JvmField val CARD_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + @JvmField val CARD_AUTHORIZATION_CHALLENGE_RESPONSE = of("card_authorization.challenge_response") @@ -571,6 +573,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -636,6 +639,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -704,6 +708,7 @@ private constructor( BALANCE_UPDATED -> Value.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Value.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED @@ -777,6 +782,7 @@ private constructor( BALANCE_UPDATED -> Known.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Known.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt index e799a871..9213a668 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt @@ -686,6 +686,10 @@ private constructor( * - balance.updated: Financial Account Balance Update * - book_transfer_transaction.created: Occurs when a book transfer transaction is created. * - book_transfer_transaction.updated: Occurs when a book transfer transaction is updated. + * - card_authorization.challenge: Occurs when an Out of Band challenge is issued during card + * authorization. The card program should issue its own challenge to the cardholder and then + * respond via + * [/v1/card_authorizations/{event_token}/challenge_response](https://docs.lithic.com/reference/respondtoauthorizationchallenge). * - card_authorization.challenge_response: Occurs when a cardholder responds to an SMS * challenge during card authorization. * - card_transaction.enhanced_data.created: Occurs when L2/L3 enhanced commercial data is @@ -793,6 +797,8 @@ private constructor( @JvmField val BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + @JvmField val CARD_AUTHORIZATION_CHALLENGE = of("card_authorization.challenge") + @JvmField val CARD_AUTHORIZATION_CHALLENGE_RESPONSE = of("card_authorization.challenge_response") @@ -912,6 +918,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -977,6 +984,7 @@ private constructor( BALANCE_UPDATED, BOOK_TRANSFER_TRANSACTION_CREATED, BOOK_TRANSFER_TRANSACTION_UPDATED, + CARD_AUTHORIZATION_CHALLENGE, CARD_AUTHORIZATION_CHALLENGE_RESPONSE, CARD_TRANSACTION_ENHANCED_DATA_CREATED, CARD_TRANSACTION_ENHANCED_DATA_UPDATED, @@ -1045,6 +1053,7 @@ private constructor( BALANCE_UPDATED -> Value.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Value.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Value.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED @@ -1118,6 +1127,7 @@ private constructor( BALANCE_UPDATED -> Known.BALANCE_UPDATED BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + CARD_AUTHORIZATION_CHALLENGE -> Known.CARD_AUTHORIZATION_CHALLENGE CARD_AUTHORIZATION_CHALLENGE_RESPONSE -> Known.CARD_AUTHORIZATION_CHALLENGE_RESPONSE CARD_TRANSACTION_ENHANCED_DATA_CREATED -> Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ParsedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ParsedWebhookEvent.kt index 71e7bea2..120baf35 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ParsedWebhookEvent.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ParsedWebhookEvent.kt @@ -45,6 +45,7 @@ private constructor( private val accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent? = null, private val cardAuthorizationApprovalRequest: CardAuthorizationApprovalRequestWebhookEvent? = null, + private val cardAuthorizationChallenge: CardAuthorizationChallengeWebhookEvent? = null, private val cardAuthorizationChallengeResponse: CardAuthorizationChallengeResponseWebhookEvent? = null, @@ -137,9 +138,13 @@ private constructor( fun accountHolderDocumentUpdated(): Optional = Optional.ofNullable(accountHolderDocumentUpdated) + /** The Auth Stream Access request payload that was sent to the ASA responder. */ fun cardAuthorizationApprovalRequest(): Optional = Optional.ofNullable(cardAuthorizationApprovalRequest) + fun cardAuthorizationChallenge(): Optional = + Optional.ofNullable(cardAuthorizationChallenge) + fun cardAuthorizationChallengeResponse(): Optional = Optional.ofNullable(cardAuthorizationChallengeResponse) @@ -326,6 +331,8 @@ private constructor( fun isCardAuthorizationApprovalRequest(): Boolean = cardAuthorizationApprovalRequest != null + fun isCardAuthorizationChallenge(): Boolean = cardAuthorizationChallenge != null + fun isCardAuthorizationChallengeResponse(): Boolean = cardAuthorizationChallengeResponse != null fun isAuthRulesBacktestReportCreated(): Boolean = authRulesBacktestReportCreated != null @@ -452,9 +459,13 @@ private constructor( fun asAccountHolderDocumentUpdated(): AccountHolderDocumentUpdatedWebhookEvent = accountHolderDocumentUpdated.getOrThrow("accountHolderDocumentUpdated") + /** The Auth Stream Access request payload that was sent to the ASA responder. */ fun asCardAuthorizationApprovalRequest(): CardAuthorizationApprovalRequestWebhookEvent = cardAuthorizationApprovalRequest.getOrThrow("cardAuthorizationApprovalRequest") + fun asCardAuthorizationChallenge(): CardAuthorizationChallengeWebhookEvent = + cardAuthorizationChallenge.getOrThrow("cardAuthorizationChallenge") + fun asCardAuthorizationChallengeResponse(): CardAuthorizationChallengeResponseWebhookEvent = cardAuthorizationChallengeResponse.getOrThrow("cardAuthorizationChallengeResponse") @@ -676,6 +687,8 @@ private constructor( visitor.visitAccountHolderDocumentUpdated(accountHolderDocumentUpdated) cardAuthorizationApprovalRequest != null -> visitor.visitCardAuthorizationApprovalRequest(cardAuthorizationApprovalRequest) + cardAuthorizationChallenge != null -> + visitor.visitCardAuthorizationChallenge(cardAuthorizationChallenge) cardAuthorizationChallengeResponse != null -> visitor.visitCardAuthorizationChallengeResponse(cardAuthorizationChallengeResponse) authRulesBacktestReportCreated != null -> @@ -830,6 +843,12 @@ private constructor( cardAuthorizationApprovalRequest.validate() } + override fun visitCardAuthorizationChallenge( + cardAuthorizationChallenge: CardAuthorizationChallengeWebhookEvent + ) { + cardAuthorizationChallenge.validate() + } + override fun visitCardAuthorizationChallengeResponse( cardAuthorizationChallengeResponse: CardAuthorizationChallengeResponseWebhookEvent @@ -1169,6 +1188,10 @@ private constructor( cardAuthorizationApprovalRequest: CardAuthorizationApprovalRequestWebhookEvent ) = cardAuthorizationApprovalRequest.validity() + override fun visitCardAuthorizationChallenge( + cardAuthorizationChallenge: CardAuthorizationChallengeWebhookEvent + ) = cardAuthorizationChallenge.validity() + override fun visitCardAuthorizationChallengeResponse( cardAuthorizationChallengeResponse: CardAuthorizationChallengeResponseWebhookEvent @@ -1389,6 +1412,7 @@ private constructor( accountHolderVerification == other.accountHolderVerification && accountHolderDocumentUpdated == other.accountHolderDocumentUpdated && cardAuthorizationApprovalRequest == other.cardAuthorizationApprovalRequest && + cardAuthorizationChallenge == other.cardAuthorizationChallenge && cardAuthorizationChallengeResponse == other.cardAuthorizationChallengeResponse && authRulesBacktestReportCreated == other.authRulesBacktestReportCreated && balanceUpdated == other.balanceUpdated && @@ -1456,6 +1480,7 @@ private constructor( accountHolderVerification, accountHolderDocumentUpdated, cardAuthorizationApprovalRequest, + cardAuthorizationChallenge, cardAuthorizationChallengeResponse, authRulesBacktestReportCreated, balanceUpdated, @@ -1522,6 +1547,8 @@ private constructor( "ParsedWebhookEvent{accountHolderDocumentUpdated=$accountHolderDocumentUpdated}" cardAuthorizationApprovalRequest != null -> "ParsedWebhookEvent{cardAuthorizationApprovalRequest=$cardAuthorizationApprovalRequest}" + cardAuthorizationChallenge != null -> + "ParsedWebhookEvent{cardAuthorizationChallenge=$cardAuthorizationChallenge}" cardAuthorizationChallengeResponse != null -> "ParsedWebhookEvent{cardAuthorizationChallengeResponse=$cardAuthorizationChallengeResponse}" authRulesBacktestReportCreated != null -> @@ -1646,11 +1673,17 @@ private constructor( accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent ) = ParsedWebhookEvent(accountHolderDocumentUpdated = accountHolderDocumentUpdated) + /** The Auth Stream Access request payload that was sent to the ASA responder. */ @JvmStatic fun ofCardAuthorizationApprovalRequest( cardAuthorizationApprovalRequest: CardAuthorizationApprovalRequestWebhookEvent ) = ParsedWebhookEvent(cardAuthorizationApprovalRequest = cardAuthorizationApprovalRequest) + @JvmStatic + fun ofCardAuthorizationChallenge( + cardAuthorizationChallenge: CardAuthorizationChallengeWebhookEvent + ) = ParsedWebhookEvent(cardAuthorizationChallenge = cardAuthorizationChallenge) + @JvmStatic fun ofCardAuthorizationChallengeResponse( cardAuthorizationChallengeResponse: CardAuthorizationChallengeResponseWebhookEvent @@ -1967,10 +2000,15 @@ private constructor( accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent ): T + /** The Auth Stream Access request payload that was sent to the ASA responder. */ fun visitCardAuthorizationApprovalRequest( cardAuthorizationApprovalRequest: CardAuthorizationApprovalRequestWebhookEvent ): T + fun visitCardAuthorizationChallenge( + cardAuthorizationChallenge: CardAuthorizationChallengeWebhookEvent + ): T + fun visitCardAuthorizationChallengeResponse( cardAuthorizationChallengeResponse: CardAuthorizationChallengeResponseWebhookEvent ): T @@ -2224,6 +2262,13 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(cardAuthorizationChallenge = it, _json = json) + }, tryDeserialize( node, jacksonTypeRef(), @@ -2578,6 +2623,8 @@ private constructor( generator.writeObject(value.accountHolderDocumentUpdated) value.cardAuthorizationApprovalRequest != null -> generator.writeObject(value.cardAuthorizationApprovalRequest) + value.cardAuthorizationChallenge != null -> + generator.writeObject(value.cardAuthorizationChallenge) value.cardAuthorizationChallengeResponse != null -> generator.writeObject(value.cardAuthorizationChallengeResponse) value.authRulesBacktestReportCreated != null -> diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsync.kt new file mode 100644 index 00000000..5288e272 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsync.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.models.CardAuthorizationChallengeResponseParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardAuthorizationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardAuthorizationServiceAsync + + /** + * Card program's response to Authorization Challenge. Programs that have Authorization + * Challenges configured as Out of Band receive a + * [card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge) + * webhook when an authorization attempt triggers a challenge. The card program should respond + * using this endpoint after the cardholder completes the challenge. + */ + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + ): CompletableFuture = challengeResponse(eventToken, params, RequestOptions.none()) + + /** @see challengeResponse */ + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + challengeResponse(params.toBuilder().eventToken(eventToken).build(), requestOptions) + + /** @see challengeResponse */ + fun challengeResponse( + params: CardAuthorizationChallengeResponseParams + ): CompletableFuture = challengeResponse(params, RequestOptions.none()) + + /** @see challengeResponse */ + fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [CardAuthorizationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardAuthorizationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /v1/card_authorizations/{event_token}/challenge_response`, but is otherwise the same as + * [CardAuthorizationServiceAsync.challengeResponse]. + */ + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + ): CompletableFuture = + challengeResponse(eventToken, params, RequestOptions.none()) + + /** @see challengeResponse */ + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + challengeResponse(params.toBuilder().eventToken(eventToken).build(), requestOptions) + + /** @see challengeResponse */ + fun challengeResponse( + params: CardAuthorizationChallengeResponseParams + ): CompletableFuture = challengeResponse(params, RequestOptions.none()) + + /** @see challengeResponse */ + fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsyncImpl.kt new file mode 100644 index 00000000..90debc9d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.json +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepareAsync +import com.lithic.api.models.CardAuthorizationChallengeResponseParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardAuthorizationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : CardAuthorizationServiceAsync { + + private val withRawResponse: CardAuthorizationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardAuthorizationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): CardAuthorizationServiceAsync = + CardAuthorizationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/card_authorizations/{event_token}/challenge_response + withRawResponse().challengeResponse(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardAuthorizationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardAuthorizationServiceAsync.WithRawResponse = + CardAuthorizationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val challengeResponseHandler: Handler = emptyHandler() + + override fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("eventToken", params.eventToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "card_authorizations", + params._pathParam(0), + "challenge_response", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { challengeResponseHandler.handle(it) } + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardAuthorizationService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardAuthorizationService.kt new file mode 100644 index 00000000..bda18fae --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardAuthorizationService.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.models.CardAuthorizationChallengeResponseParams +import java.util.function.Consumer + +interface CardAuthorizationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardAuthorizationService + + /** + * Card program's response to Authorization Challenge. Programs that have Authorization + * Challenges configured as Out of Band receive a + * [card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge) + * webhook when an authorization attempt triggers a challenge. The card program should respond + * using this endpoint after the cardholder completes the challenge. + */ + fun challengeResponse(eventToken: String, params: CardAuthorizationChallengeResponseParams) = + challengeResponse(eventToken, params, RequestOptions.none()) + + /** @see challengeResponse */ + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = challengeResponse(params.toBuilder().eventToken(eventToken).build(), requestOptions) + + /** @see challengeResponse */ + fun challengeResponse(params: CardAuthorizationChallengeResponseParams) = + challengeResponse(params, RequestOptions.none()) + + /** @see challengeResponse */ + fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * A view of [CardAuthorizationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardAuthorizationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /v1/card_authorizations/{event_token}/challenge_response`, but is otherwise the same as + * [CardAuthorizationService.challengeResponse]. + */ + @MustBeClosed + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + ): HttpResponse = challengeResponse(eventToken, params, RequestOptions.none()) + + /** @see challengeResponse */ + @MustBeClosed + fun challengeResponse( + eventToken: String, + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + challengeResponse(params.toBuilder().eventToken(eventToken).build(), requestOptions) + + /** @see challengeResponse */ + @MustBeClosed + fun challengeResponse(params: CardAuthorizationChallengeResponseParams): HttpResponse = + challengeResponse(params, RequestOptions.none()) + + /** @see challengeResponse */ + @MustBeClosed + fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardAuthorizationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardAuthorizationServiceImpl.kt new file mode 100644 index 00000000..b754fb64 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardAuthorizationServiceImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.emptyHandler +import com.lithic.api.core.handlers.errorBodyHandler +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.json +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepare +import com.lithic.api.models.CardAuthorizationChallengeResponseParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardAuthorizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardAuthorizationService { + + private val withRawResponse: CardAuthorizationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardAuthorizationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardAuthorizationService = + CardAuthorizationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions, + ) { + // post /v1/card_authorizations/{event_token}/challenge_response + withRawResponse().challengeResponse(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardAuthorizationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardAuthorizationService.WithRawResponse = + CardAuthorizationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val challengeResponseHandler: Handler = emptyHandler() + + override fun challengeResponse( + params: CardAuthorizationChallengeResponseParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("eventToken", params.eventToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "card_authorizations", + params._pathParam(0), + "challenge_response", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { challengeResponseHandler.handle(it) } + } + } + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEventTest.kt index e15a9abd..c94f591c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEventTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationApprovalRequestWebhookEventTest.kt @@ -18,29 +18,28 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .acquirerFee(0L) .amount(0L) .amounts( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.builder() + CardAuthorization.Amounts.builder() .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.ConvertedAmount - .builder() + CardAuthorization.Amounts.ConvertedAmount.builder() .amount(0L) .conversionRate("1.000000") .currency("USD") .build() ) .hold( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .settlement( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() @@ -49,44 +48,30 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) .authorizationAmount(0L) .avs( - CardAuthorizationApprovalRequestWebhookEvent.Avs.builder() + CardAuthorization.Avs.builder() .address("address") - .addressOnFileMatch( - CardAuthorizationApprovalRequestWebhookEvent.Avs.AddressMatchResult - .MATCH - ) + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) .zipcode("zipcode") .build() ) .card( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.builder() + CardAuthorization.AsaRequestCard.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .lastFour("last_four") .memo("memo") .spendLimit(0L) .spendLimitDuration( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard - .SpendLimitDuration - .ANNUALLY - ) - .state( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.State.CLOSED - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.CardType - .SINGLE_USE + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) .build() ) .cardholderCurrency("cardholder_currency") .cashAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType( - CardAuthorizationApprovalRequestWebhookEvent.EventType - .CARD_AUTHORIZATION_APPROVAL_REQUEST - ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.TransactionMerchant.builder() + CardAuthorization.TransactionMerchant.builder() .acceptorId("333301802529120") .acquiringInstitutionId("191231") .city("NEW YORK") @@ -102,7 +87,7 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .merchantAmount(0L) .merchantCurrency("USD") .serviceLocation( - CardAuthorizationApprovalRequestWebhookEvent.ServiceLocation.builder() + CardAuthorization.ServiceLocation.builder() .city("city") .country("country") .postalCode("postal_code") @@ -111,11 +96,9 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .settledAmount(0L) - .status(CardAuthorizationApprovalRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) - .transactionInitiator( - CardAuthorizationApprovalRequestWebhookEvent.TransactionInitiator.CARDHOLDER - ) - .accountType(CardAuthorizationApprovalRequestWebhookEvent.AccountType.CHECKING) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) .cardholderAuthentication( CardholderAuthentication.builder() .authenticationMethod( @@ -131,15 +114,12 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .conversionRate(0.0) .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .fleetInfo( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo.builder() + CardAuthorization.AsaRequestFleetInfo.builder() .fleetPromptCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetPromptCode - .NO_PROMPT + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT ) .fleetRestrictionCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetRestrictionCode + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode .NO_RESTRICTIONS ) .driverNumber("driver_number") @@ -147,27 +127,23 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .latestChallenge( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.builder() + CardAuthorization.LatestChallenge.builder() .phoneNumber("phone_number") - .status( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.Status - .COMPLETED - ) + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .network(CardAuthorizationApprovalRequestWebhookEvent.Network.AMEX) + .network(CardAuthorization.Network.AMEX) .networkRiskScore(0L) .networkSpecificData( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData.builder() + CardAuthorization.AsaNetworkSpecificData.builder() .mastercard( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .builder() .ecommerceSecurityLevelIndicator("xxx") .addOnBehalfServiceResult( - CardAuthorizationApprovalRequestWebhookEvent - .AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .OnBehalfServiceResult .builder() @@ -180,8 +156,7 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .visa( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .AsaNetworkSpecificDataVisa + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa .builder() .businessApplicationIdentifier("xx") .build() @@ -189,53 +164,31 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .pos( - CardAuthorizationApprovalRequestWebhookEvent.Pos.builder() + CardAuthorization.Pos.builder() .entryMode( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaRequestPosEntryMode - .builder() - .card( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Card - .PRESENT - ) + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Cardholder + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder .DEFERRED_BILLING ) - .pan( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Pan - .AUTO_ENTRY - ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) .pinEntered(true) .build() ) .terminal( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .builder() + CardAuthorization.Pos.AsaPosTerminal.builder() .attended(true) .cardRetentionCapable(true) .onPremise(true) .operator( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Operator - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE ) .partialApprovalCapable(true) .pinCapability( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .PinCapability - .CAPABLE - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Type - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) .acceptorTerminalId("5([<,yN%") .build() ) @@ -243,6 +196,10 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + CardAuthorizationApprovalRequestWebhookEvent.EventType + .CARD_AUTHORIZATION_APPROVAL_REQUEST + ) .build() assertThat(cardAuthorizationApprovalRequestWebhookEvent.token()) @@ -251,29 +208,28 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { assertThat(cardAuthorizationApprovalRequestWebhookEvent.amount()).isEqualTo(0L) assertThat(cardAuthorizationApprovalRequestWebhookEvent.amounts()) .isEqualTo( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.builder() + CardAuthorization.Amounts.builder() .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.ConvertedAmount - .builder() + CardAuthorization.Amounts.ConvertedAmount.builder() .amount(0L) .conversionRate("1.000000") .currency("USD") .build() ) .hold( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .settlement( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() @@ -283,31 +239,24 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { assertThat(cardAuthorizationApprovalRequestWebhookEvent.authorizationAmount()).isEqualTo(0L) assertThat(cardAuthorizationApprovalRequestWebhookEvent.avs()) .isEqualTo( - CardAuthorizationApprovalRequestWebhookEvent.Avs.builder() + CardAuthorization.Avs.builder() .address("address") - .addressOnFileMatch( - CardAuthorizationApprovalRequestWebhookEvent.Avs.AddressMatchResult.MATCH - ) + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) .zipcode("zipcode") .build() ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.card()) .isEqualTo( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.builder() + CardAuthorization.AsaRequestCard.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .lastFour("last_four") .memo("memo") .spendLimit(0L) .spendLimitDuration( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard - .SpendLimitDuration - .ANNUALLY - ) - .state(CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.State.CLOSED) - .type( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.CardType - .SINGLE_USE + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) .build() ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.cardholderCurrency()) @@ -315,14 +264,9 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { assertThat(cardAuthorizationApprovalRequestWebhookEvent.cashAmount()).isEqualTo(0L) assertThat(cardAuthorizationApprovalRequestWebhookEvent.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(cardAuthorizationApprovalRequestWebhookEvent.eventType()) - .isEqualTo( - CardAuthorizationApprovalRequestWebhookEvent.EventType - .CARD_AUTHORIZATION_APPROVAL_REQUEST - ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.merchant()) .isEqualTo( - CardAuthorizationApprovalRequestWebhookEvent.TransactionMerchant.builder() + CardAuthorization.TransactionMerchant.builder() .acceptorId("333301802529120") .acquiringInstitutionId("191231") .city("NEW YORK") @@ -339,7 +283,7 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { assertThat(cardAuthorizationApprovalRequestWebhookEvent.merchantCurrency()).isEqualTo("USD") assertThat(cardAuthorizationApprovalRequestWebhookEvent.serviceLocation()) .contains( - CardAuthorizationApprovalRequestWebhookEvent.ServiceLocation.builder() + CardAuthorization.ServiceLocation.builder() .city("city") .country("country") .postalCode("postal_code") @@ -349,11 +293,11 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.settledAmount()).isEqualTo(0L) assertThat(cardAuthorizationApprovalRequestWebhookEvent.status()) - .isEqualTo(CardAuthorizationApprovalRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) + .isEqualTo(CardAuthorization.AsaRequestStatus.AUTHORIZATION) assertThat(cardAuthorizationApprovalRequestWebhookEvent.transactionInitiator()) - .isEqualTo(CardAuthorizationApprovalRequestWebhookEvent.TransactionInitiator.CARDHOLDER) + .isEqualTo(CardAuthorization.TransactionInitiator.CARDHOLDER) assertThat(cardAuthorizationApprovalRequestWebhookEvent.accountType()) - .contains(CardAuthorizationApprovalRequestWebhookEvent.AccountType.CHECKING) + .contains(CardAuthorization.AccountType.CHECKING) assertThat(cardAuthorizationApprovalRequestWebhookEvent.cardholderAuthentication()) .contains( CardholderAuthentication.builder() @@ -372,16 +316,12 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(cardAuthorizationApprovalRequestWebhookEvent.fleetInfo()) .contains( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo.builder() + CardAuthorization.AsaRequestFleetInfo.builder() .fleetPromptCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetPromptCode - .NO_PROMPT + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT ) .fleetRestrictionCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetRestrictionCode - .NO_RESTRICTIONS + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode.NO_RESTRICTIONS ) .driverNumber("driver_number") .vehicleNumber("vehicle_number") @@ -389,28 +329,24 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.latestChallenge()) .contains( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.builder() + CardAuthorization.LatestChallenge.builder() .phoneNumber("phone_number") - .status( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.Status - .COMPLETED - ) + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.network()) - .contains(CardAuthorizationApprovalRequestWebhookEvent.Network.AMEX) + .contains(CardAuthorization.Network.AMEX) assertThat(cardAuthorizationApprovalRequestWebhookEvent.networkRiskScore()).contains(0L) assertThat(cardAuthorizationApprovalRequestWebhookEvent.networkSpecificData()) .contains( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData.builder() + CardAuthorization.AsaNetworkSpecificData.builder() .mastercard( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .AsaNetworkSpecificDataMastercard + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataMastercard .builder() .ecommerceSecurityLevelIndicator("xxx") .addOnBehalfServiceResult( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .OnBehalfServiceResult .builder() @@ -423,8 +359,7 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .visa( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .AsaNetworkSpecificDataVisa + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa .builder() .businessApplicationIdentifier("xx") .build() @@ -433,51 +368,29 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) assertThat(cardAuthorizationApprovalRequestWebhookEvent.pos()) .contains( - CardAuthorizationApprovalRequestWebhookEvent.Pos.builder() + CardAuthorization.Pos.builder() .entryMode( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaRequestPosEntryMode - .builder() - .card( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Card - .PRESENT - ) + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Cardholder + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder .DEFERRED_BILLING ) - .pan( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Pan - .AUTO_ENTRY - ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) .pinEntered(true) .build() ) .terminal( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal.builder() + CardAuthorization.Pos.AsaPosTerminal.builder() .attended(true) .cardRetentionCapable(true) .onPremise(true) - .operator( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Operator - .ADMINISTRATIVE - ) + .operator(CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE) .partialApprovalCapable(true) .pinCapability( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .PinCapability - .CAPABLE - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal.Type - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) .acceptorTerminalId("5([<,yN%") .build() ) @@ -487,6 +400,11 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .contains(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) assertThat(cardAuthorizationApprovalRequestWebhookEvent.ttl()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(cardAuthorizationApprovalRequestWebhookEvent.eventType()) + .isEqualTo( + CardAuthorizationApprovalRequestWebhookEvent.EventType + .CARD_AUTHORIZATION_APPROVAL_REQUEST + ) } @Test @@ -498,29 +416,28 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .acquirerFee(0L) .amount(0L) .amounts( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.builder() + CardAuthorization.Amounts.builder() .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.ConvertedAmount - .builder() + CardAuthorization.Amounts.ConvertedAmount.builder() .amount(0L) .conversionRate("1.000000") .currency("USD") .build() ) .hold( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .settlement( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() @@ -529,44 +446,30 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) .authorizationAmount(0L) .avs( - CardAuthorizationApprovalRequestWebhookEvent.Avs.builder() + CardAuthorization.Avs.builder() .address("address") - .addressOnFileMatch( - CardAuthorizationApprovalRequestWebhookEvent.Avs.AddressMatchResult - .MATCH - ) + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) .zipcode("zipcode") .build() ) .card( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.builder() + CardAuthorization.AsaRequestCard.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .lastFour("last_four") .memo("memo") .spendLimit(0L) .spendLimitDuration( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard - .SpendLimitDuration - .ANNUALLY - ) - .state( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.State.CLOSED - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.CardType - .SINGLE_USE + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) .build() ) .cardholderCurrency("cardholder_currency") .cashAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType( - CardAuthorizationApprovalRequestWebhookEvent.EventType - .CARD_AUTHORIZATION_APPROVAL_REQUEST - ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.TransactionMerchant.builder() + CardAuthorization.TransactionMerchant.builder() .acceptorId("333301802529120") .acquiringInstitutionId("191231") .city("NEW YORK") @@ -582,7 +485,7 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .merchantAmount(0L) .merchantCurrency("USD") .serviceLocation( - CardAuthorizationApprovalRequestWebhookEvent.ServiceLocation.builder() + CardAuthorization.ServiceLocation.builder() .city("city") .country("country") .postalCode("postal_code") @@ -591,11 +494,9 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .settledAmount(0L) - .status(CardAuthorizationApprovalRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) - .transactionInitiator( - CardAuthorizationApprovalRequestWebhookEvent.TransactionInitiator.CARDHOLDER - ) - .accountType(CardAuthorizationApprovalRequestWebhookEvent.AccountType.CHECKING) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) .cardholderAuthentication( CardholderAuthentication.builder() .authenticationMethod( @@ -611,15 +512,12 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .conversionRate(0.0) .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .fleetInfo( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo.builder() + CardAuthorization.AsaRequestFleetInfo.builder() .fleetPromptCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetPromptCode - .NO_PROMPT + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT ) .fleetRestrictionCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetRestrictionCode + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode .NO_RESTRICTIONS ) .driverNumber("driver_number") @@ -627,27 +525,23 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .latestChallenge( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.builder() + CardAuthorization.LatestChallenge.builder() .phoneNumber("phone_number") - .status( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.Status - .COMPLETED - ) + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .network(CardAuthorizationApprovalRequestWebhookEvent.Network.AMEX) + .network(CardAuthorization.Network.AMEX) .networkRiskScore(0L) .networkSpecificData( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData.builder() + CardAuthorization.AsaNetworkSpecificData.builder() .mastercard( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .builder() .ecommerceSecurityLevelIndicator("xxx") .addOnBehalfServiceResult( - CardAuthorizationApprovalRequestWebhookEvent - .AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .OnBehalfServiceResult .builder() @@ -660,8 +554,7 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .visa( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .AsaNetworkSpecificDataVisa + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa .builder() .businessApplicationIdentifier("xx") .build() @@ -669,53 +562,31 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { .build() ) .pos( - CardAuthorizationApprovalRequestWebhookEvent.Pos.builder() + CardAuthorization.Pos.builder() .entryMode( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaRequestPosEntryMode - .builder() - .card( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Card - .PRESENT - ) + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Cardholder + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder .DEFERRED_BILLING ) - .pan( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Pan - .AUTO_ENTRY - ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) .pinEntered(true) .build() ) .terminal( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .builder() + CardAuthorization.Pos.AsaPosTerminal.builder() .attended(true) .cardRetentionCapable(true) .onPremise(true) .operator( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Operator - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE ) .partialApprovalCapable(true) .pinCapability( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .PinCapability - .CAPABLE - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Type - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) .acceptorTerminalId("5([<,yN%") .build() ) @@ -723,6 +594,10 @@ internal class CardAuthorizationApprovalRequestWebhookEventTest { ) .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + CardAuthorizationApprovalRequestWebhookEvent.EventType + .CARD_AUTHORIZATION_APPROVAL_REQUEST + ) .build() val roundtrippedCardAuthorizationApprovalRequestWebhookEvent = diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationChallengeResponseParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationChallengeResponseParamsTest.kt new file mode 100644 index 00000000..45a0daa7 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationChallengeResponseParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardAuthorizationChallengeResponseParamsTest { + + @Test + fun create() { + CardAuthorizationChallengeResponseParams.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .response(CardAuthorizationChallengeResponseParams.Response.APPROVE) + .build() + } + + @Test + fun pathParams() { + val params = + CardAuthorizationChallengeResponseParams.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .response(CardAuthorizationChallengeResponseParams.Response.APPROVE) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + CardAuthorizationChallengeResponseParams.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .response(CardAuthorizationChallengeResponseParams.Response.APPROVE) + .build() + + val body = params._body() + + assertThat(body.response()) + .isEqualTo(CardAuthorizationChallengeResponseParams.Response.APPROVE) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationChallengeWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationChallengeWebhookEventTest.kt new file mode 100644 index 00000000..48c8629a --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationChallengeWebhookEventTest.kt @@ -0,0 +1,674 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardAuthorizationChallengeWebhookEventTest { + + @Test + fun create() { + val cardAuthorizationChallengeWebhookEvent = + CardAuthorizationChallengeWebhookEvent.builder() + .authorization( + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult( + CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card( + CardAuthorization.Pos.AsaRequestPosEntryMode.Card + .PRESENT + ) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + CardAuthorization.Pos.AsaRequestPosEntryMode.Pan + .AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability + .CAPABLE + ) + .type( + CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE + ) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo( + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + ) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .challenge( + CardAuthorizationChallengeWebhookEvent.AuthorizationChallenge.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + CardAuthorizationChallengeWebhookEvent.EventType.CARD_AUTHORIZATION_CHALLENGE + ) + .build() + + assertThat(cardAuthorizationChallengeWebhookEvent.authorization()) + .isEqualTo( + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult( + CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.LITHIC_RULES) + .liabilityShift( + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo( + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + ) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(cardAuthorizationChallengeWebhookEvent.challenge()) + .isEqualTo( + CardAuthorizationChallengeWebhookEvent.AuthorizationChallenge.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(cardAuthorizationChallengeWebhookEvent.eventType()) + .isEqualTo( + CardAuthorizationChallengeWebhookEvent.EventType.CARD_AUTHORIZATION_CHALLENGE + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardAuthorizationChallengeWebhookEvent = + CardAuthorizationChallengeWebhookEvent.builder() + .authorization( + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult( + CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card( + CardAuthorization.Pos.AsaRequestPosEntryMode.Card + .PRESENT + ) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + CardAuthorization.Pos.AsaRequestPosEntryMode.Pan + .AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability + .CAPABLE + ) + .type( + CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE + ) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo( + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + ) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .challenge( + CardAuthorizationChallengeWebhookEvent.AuthorizationChallenge.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + CardAuthorizationChallengeWebhookEvent.EventType.CARD_AUTHORIZATION_CHALLENGE + ) + .build() + + val roundtrippedCardAuthorizationChallengeWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardAuthorizationChallengeWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardAuthorizationChallengeWebhookEvent) + .isEqualTo(cardAuthorizationChallengeWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationTest.kt new file mode 100644 index 00000000..c9b68119 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardAuthorizationTest.kt @@ -0,0 +1,593 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardAuthorizationTest { + + @Test + fun create() { + val cardAuthorization = + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.LITHIC_RULES) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(cardAuthorization.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardAuthorization.acquirerFee()).isEqualTo(0L) + assertThat(cardAuthorization.amount()).isEqualTo(0L) + assertThat(cardAuthorization.amounts()) + .isEqualTo( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + assertThat(cardAuthorization.authorizationAmount()).isEqualTo(0L) + assertThat(cardAuthorization.avs()) + .isEqualTo( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + assertThat(cardAuthorization.card()) + .isEqualTo( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + assertThat(cardAuthorization.cardholderCurrency()).isEqualTo("cardholder_currency") + assertThat(cardAuthorization.cashAmount()).isEqualTo(0L) + assertThat(cardAuthorization.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(cardAuthorization.merchant()) + .isEqualTo( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + assertThat(cardAuthorization.merchantAmount()).isEqualTo(0L) + assertThat(cardAuthorization.merchantCurrency()).isEqualTo("USD") + assertThat(cardAuthorization.serviceLocation()) + .contains( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + assertThat(cardAuthorization.settledAmount()).isEqualTo(0L) + assertThat(cardAuthorization.status()) + .isEqualTo(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + assertThat(cardAuthorization.transactionInitiator()) + .isEqualTo(CardAuthorization.TransactionInitiator.CARDHOLDER) + assertThat(cardAuthorization.accountType()).contains(CardAuthorization.AccountType.CHECKING) + assertThat(cardAuthorization.cardholderAuthentication()) + .contains( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.LITHIC_RULES) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + assertThat(cardAuthorization.cashback()).contains(0L) + assertThat(cardAuthorization.conversionRate()).contains(0.0) + assertThat(cardAuthorization.eventToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardAuthorization.fleetInfo()) + .contains( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode.NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + assertThat(cardAuthorization.latestChallenge()) + .contains( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(cardAuthorization.network()).contains(CardAuthorization.Network.AMEX) + assertThat(cardAuthorization.networkRiskScore()).contains(0L) + assertThat(cardAuthorization.networkSpecificData()) + .contains( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + assertThat(cardAuthorization.pos()) + .contains( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator(CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + assertThat(cardAuthorization.tokenInfo()) + .contains(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + assertThat(cardAuthorization.ttl()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardAuthorization = + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.LITHIC_RULES) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedCardAuthorization = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardAuthorization), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardAuthorization).isEqualTo(cardAuthorization) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalValueTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalValueTest.kt index 62d66056..03e3fce9 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalValueTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalValueTest.kt @@ -22,6 +22,7 @@ internal class ConditionalValueTest { val conditionalValue = ConditionalValue.ofRegex(regex) assertThat(conditionalValue.regex()).contains(regex) + assertThat(conditionalValue.integer()).isEmpty assertThat(conditionalValue.number()).isEmpty assertThat(conditionalValue.listOfStrings()).isEmpty assertThat(conditionalValue.timestamp()).isEmpty @@ -41,13 +42,41 @@ internal class ConditionalValueTest { assertThat(roundtrippedConditionalValue).isEqualTo(conditionalValue) } + @Test + fun ofInteger() { + val integer = 0L + + val conditionalValue = ConditionalValue.ofInteger(integer) + + assertThat(conditionalValue.regex()).isEmpty + assertThat(conditionalValue.integer()).contains(integer) + assertThat(conditionalValue.number()).isEmpty + assertThat(conditionalValue.listOfStrings()).isEmpty + assertThat(conditionalValue.timestamp()).isEmpty + } + + @Test + fun ofIntegerRoundtrip() { + val jsonMapper = jsonMapper() + val conditionalValue = ConditionalValue.ofInteger(0L) + + val roundtrippedConditionalValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(conditionalValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConditionalValue).isEqualTo(conditionalValue) + } + @Test fun ofNumber() { - val number = 0L + val number = 0.0 val conditionalValue = ConditionalValue.ofNumber(number) assertThat(conditionalValue.regex()).isEmpty + assertThat(conditionalValue.integer()).isEmpty assertThat(conditionalValue.number()).contains(number) assertThat(conditionalValue.listOfStrings()).isEmpty assertThat(conditionalValue.timestamp()).isEmpty @@ -56,7 +85,7 @@ internal class ConditionalValueTest { @Test fun ofNumberRoundtrip() { val jsonMapper = jsonMapper() - val conditionalValue = ConditionalValue.ofNumber(0L) + val conditionalValue = ConditionalValue.ofNumber(0.0) val roundtrippedConditionalValue = jsonMapper.readValue( @@ -74,6 +103,7 @@ internal class ConditionalValueTest { val conditionalValue = ConditionalValue.ofListOfStrings(listOfStrings) assertThat(conditionalValue.regex()).isEmpty + assertThat(conditionalValue.integer()).isEmpty assertThat(conditionalValue.number()).isEmpty assertThat(conditionalValue.listOfStrings()).contains(listOfStrings) assertThat(conditionalValue.timestamp()).isEmpty @@ -100,6 +130,7 @@ internal class ConditionalValueTest { val conditionalValue = ConditionalValue.ofTimestamp(timestamp) assertThat(conditionalValue.regex()).isEmpty + assertThat(conditionalValue.integer()).isEmpty assertThat(conditionalValue.number()).isEmpty assertThat(conditionalValue.listOfStrings()).isEmpty assertThat(conditionalValue.timestamp()).contains(timestamp) @@ -122,7 +153,6 @@ internal class ConditionalValueTest { enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), - FLOAT(JsonValue.from(3.14)), OBJECT(JsonValue.from(mapOf("invalid" to "object"))), } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ParsedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ParsedWebhookEventTest.kt index aabc1c02..02a64ffb 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ParsedWebhookEventTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ParsedWebhookEventTest.kt @@ -44,6 +44,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -216,6 +217,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -407,6 +409,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -534,6 +537,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -642,6 +646,7 @@ internal class ParsedWebhookEventTest { .contains(accountHolderVerification) assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -769,6 +774,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()) .contains(accountHolderDocumentUpdated) assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -881,29 +887,28 @@ internal class ParsedWebhookEventTest { .acquirerFee(0L) .amount(0L) .amounts( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.builder() + CardAuthorization.Amounts.builder() .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.ConvertedAmount - .builder() + CardAuthorization.Amounts.ConvertedAmount.builder() .amount(0L) .conversionRate("1.000000") .currency("USD") .build() ) .hold( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .settlement( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount.builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() @@ -912,44 +917,30 @@ internal class ParsedWebhookEventTest { ) .authorizationAmount(0L) .avs( - CardAuthorizationApprovalRequestWebhookEvent.Avs.builder() + CardAuthorization.Avs.builder() .address("address") - .addressOnFileMatch( - CardAuthorizationApprovalRequestWebhookEvent.Avs.AddressMatchResult - .MATCH - ) + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) .zipcode("zipcode") .build() ) .card( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.builder() + CardAuthorization.AsaRequestCard.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .lastFour("last_four") .memo("memo") .spendLimit(0L) .spendLimitDuration( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard - .SpendLimitDuration - .ANNUALLY - ) - .state( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.State.CLOSED - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.CardType - .SINGLE_USE + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) .build() ) .cardholderCurrency("cardholder_currency") .cashAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType( - CardAuthorizationApprovalRequestWebhookEvent.EventType - .CARD_AUTHORIZATION_APPROVAL_REQUEST - ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.TransactionMerchant.builder() + CardAuthorization.TransactionMerchant.builder() .acceptorId("333301802529120") .acquiringInstitutionId("191231") .city("NEW YORK") @@ -965,7 +956,7 @@ internal class ParsedWebhookEventTest { .merchantAmount(0L) .merchantCurrency("USD") .serviceLocation( - CardAuthorizationApprovalRequestWebhookEvent.ServiceLocation.builder() + CardAuthorization.ServiceLocation.builder() .city("city") .country("country") .postalCode("postal_code") @@ -974,11 +965,9 @@ internal class ParsedWebhookEventTest { .build() ) .settledAmount(0L) - .status(CardAuthorizationApprovalRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) - .transactionInitiator( - CardAuthorizationApprovalRequestWebhookEvent.TransactionInitiator.CARDHOLDER - ) - .accountType(CardAuthorizationApprovalRequestWebhookEvent.AccountType.CHECKING) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) .cardholderAuthentication( CardholderAuthentication.builder() .authenticationMethod( @@ -994,15 +983,12 @@ internal class ParsedWebhookEventTest { .conversionRate(0.0) .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .fleetInfo( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo.builder() + CardAuthorization.AsaRequestFleetInfo.builder() .fleetPromptCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetPromptCode - .NO_PROMPT + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT ) .fleetRestrictionCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetRestrictionCode + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode .NO_RESTRICTIONS ) .driverNumber("driver_number") @@ -1010,27 +996,23 @@ internal class ParsedWebhookEventTest { .build() ) .latestChallenge( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.builder() + CardAuthorization.LatestChallenge.builder() .phoneNumber("phone_number") - .status( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.Status - .COMPLETED - ) + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .network(CardAuthorizationApprovalRequestWebhookEvent.Network.AMEX) + .network(CardAuthorization.Network.AMEX) .networkRiskScore(0L) .networkSpecificData( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData.builder() + CardAuthorization.AsaNetworkSpecificData.builder() .mastercard( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .builder() .ecommerceSecurityLevelIndicator("xxx") .addOnBehalfServiceResult( - CardAuthorizationApprovalRequestWebhookEvent - .AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .OnBehalfServiceResult .builder() @@ -1043,8 +1025,7 @@ internal class ParsedWebhookEventTest { .build() ) .visa( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .AsaNetworkSpecificDataVisa + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa .builder() .businessApplicationIdentifier("xx") .build() @@ -1052,53 +1033,31 @@ internal class ParsedWebhookEventTest { .build() ) .pos( - CardAuthorizationApprovalRequestWebhookEvent.Pos.builder() + CardAuthorization.Pos.builder() .entryMode( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaRequestPosEntryMode - .builder() - .card( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Card - .PRESENT - ) + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Cardholder + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder .DEFERRED_BILLING ) - .pan( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Pan - .AUTO_ENTRY - ) + .pan(CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) .pinEntered(true) .build() ) .terminal( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .builder() + CardAuthorization.Pos.AsaPosTerminal.builder() .attended(true) .cardRetentionCapable(true) .onPremise(true) .operator( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Operator - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE ) .partialApprovalCapable(true) .pinCapability( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .PinCapability - .CAPABLE - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .Type - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) .acceptorTerminalId("5([<,yN%") .build() ) @@ -1106,6 +1065,10 @@ internal class ParsedWebhookEventTest { ) .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + CardAuthorizationApprovalRequestWebhookEvent.EventType + .CARD_AUTHORIZATION_APPROVAL_REQUEST + ) .build() val parsedWebhookEvent = @@ -1119,6 +1082,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()) .contains(cardAuthorizationApprovalRequest) + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -1184,32 +1148,28 @@ internal class ParsedWebhookEventTest { .acquirerFee(0L) .amount(0L) .amounts( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.builder() + CardAuthorization.Amounts.builder() .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.ConvertedAmount - .builder() + CardAuthorization.Amounts.ConvertedAmount.builder() .amount(0L) .conversionRate("1.000000") .currency("USD") .build() ) .hold( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount - .builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount - .builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() ) .settlement( - CardAuthorizationApprovalRequestWebhookEvent.Amounts.Amount - .builder() + CardAuthorization.Amounts.Amount.builder() .amount(0L) .currency("USD") .build() @@ -1218,45 +1178,30 @@ internal class ParsedWebhookEventTest { ) .authorizationAmount(0L) .avs( - CardAuthorizationApprovalRequestWebhookEvent.Avs.builder() + CardAuthorization.Avs.builder() .address("address") - .addressOnFileMatch( - CardAuthorizationApprovalRequestWebhookEvent.Avs.AddressMatchResult - .MATCH - ) + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) .zipcode("zipcode") .build() ) .card( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.builder() + CardAuthorization.AsaRequestCard.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .lastFour("last_four") .memo("memo") .spendLimit(0L) .spendLimitDuration( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard - .SpendLimitDuration - .ANNUALLY - ) - .state( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.State - .CLOSED - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestCard.CardType - .SINGLE_USE + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) .build() ) .cardholderCurrency("cardholder_currency") .cashAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType( - CardAuthorizationApprovalRequestWebhookEvent.EventType - .CARD_AUTHORIZATION_APPROVAL_REQUEST - ) .merchant( - CardAuthorizationApprovalRequestWebhookEvent.TransactionMerchant.builder() + CardAuthorization.TransactionMerchant.builder() .acceptorId("333301802529120") .acquiringInstitutionId("191231") .city("NEW YORK") @@ -1272,7 +1217,7 @@ internal class ParsedWebhookEventTest { .merchantAmount(0L) .merchantCurrency("USD") .serviceLocation( - CardAuthorizationApprovalRequestWebhookEvent.ServiceLocation.builder() + CardAuthorization.ServiceLocation.builder() .city("city") .country("country") .postalCode("postal_code") @@ -1281,13 +1226,9 @@ internal class ParsedWebhookEventTest { .build() ) .settledAmount(0L) - .status( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION - ) - .transactionInitiator( - CardAuthorizationApprovalRequestWebhookEvent.TransactionInitiator.CARDHOLDER - ) - .accountType(CardAuthorizationApprovalRequestWebhookEvent.AccountType.CHECKING) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) .cardholderAuthentication( CardholderAuthentication.builder() .authenticationMethod( @@ -1307,15 +1248,12 @@ internal class ParsedWebhookEventTest { .conversionRate(0.0) .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .fleetInfo( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo.builder() + CardAuthorization.AsaRequestFleetInfo.builder() .fleetPromptCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetPromptCode - .NO_PROMPT + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT ) .fleetRestrictionCode( - CardAuthorizationApprovalRequestWebhookEvent.AsaRequestFleetInfo - .FleetRestrictionCode + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode .NO_RESTRICTIONS ) .driverNumber("driver_number") @@ -1323,28 +1261,23 @@ internal class ParsedWebhookEventTest { .build() ) .latestChallenge( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.builder() + CardAuthorization.LatestChallenge.builder() .phoneNumber("phone_number") - .status( - CardAuthorizationApprovalRequestWebhookEvent.LatestChallenge.Status - .COMPLETED - ) + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .network(CardAuthorizationApprovalRequestWebhookEvent.Network.AMEX) + .network(CardAuthorization.Network.AMEX) .networkRiskScore(0L) .networkSpecificData( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .builder() + CardAuthorization.AsaNetworkSpecificData.builder() .mastercard( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .builder() .ecommerceSecurityLevelIndicator("xxx") .addOnBehalfServiceResult( - CardAuthorizationApprovalRequestWebhookEvent - .AsaNetworkSpecificData + CardAuthorization.AsaNetworkSpecificData .AsaNetworkSpecificDataMastercard .OnBehalfServiceResult .builder() @@ -1357,8 +1290,7 @@ internal class ParsedWebhookEventTest { .build() ) .visa( - CardAuthorizationApprovalRequestWebhookEvent.AsaNetworkSpecificData - .AsaNetworkSpecificDataVisa + CardAuthorization.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa .builder() .businessApplicationIdentifier("xx") .build() @@ -1366,57 +1298,33 @@ internal class ParsedWebhookEventTest { .build() ) .pos( - CardAuthorizationApprovalRequestWebhookEvent.Pos.builder() + CardAuthorization.Pos.builder() .entryMode( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .builder() - .card( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Card - .PRESENT - ) + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card(CardAuthorization.Pos.AsaRequestPosEntryMode.Card.PRESENT) .cardholder( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Cardholder + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder .DEFERRED_BILLING ) .pan( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaRequestPosEntryMode - .Pan - .AUTO_ENTRY + CardAuthorization.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY ) .pinEntered(true) .build() ) .terminal( - CardAuthorizationApprovalRequestWebhookEvent.Pos.AsaPosTerminal - .builder() + CardAuthorization.Pos.AsaPosTerminal.builder() .attended(true) .cardRetentionCapable(true) .onPremise(true) .operator( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaPosTerminal - .Operator - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE ) .partialApprovalCapable(true) .pinCapability( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaPosTerminal - .PinCapability - .CAPABLE - ) - .type( - CardAuthorizationApprovalRequestWebhookEvent.Pos - .AsaPosTerminal - .Type - .ADMINISTRATIVE + CardAuthorization.Pos.AsaPosTerminal.PinCapability.CAPABLE ) + .type(CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) .acceptorTerminalId("5([<,yN%") .build() ) @@ -1426,6 +1334,541 @@ internal class ParsedWebhookEventTest { TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() ) .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + CardAuthorizationApprovalRequestWebhookEvent.EventType + .CARD_AUTHORIZATION_APPROVAL_REQUEST + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardAuthorizationChallenge() { + val cardAuthorizationChallenge = + CardAuthorizationChallengeWebhookEvent.builder() + .authorization( + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch(CardAuthorization.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult( + CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card( + CardAuthorization.Pos.AsaRequestPosEntryMode.Card + .PRESENT + ) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + CardAuthorization.Pos.AsaRequestPosEntryMode.Pan + .AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability + .CAPABLE + ) + .type( + CardAuthorization.Pos.AsaPosTerminal.Type.ADMINISTRATIVE + ) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo( + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + ) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .challenge( + CardAuthorizationChallengeWebhookEvent.AuthorizationChallenge.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + CardAuthorizationChallengeWebhookEvent.EventType.CARD_AUTHORIZATION_CHALLENGE + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardAuthorizationChallenge(cardAuthorizationChallenge) + + assertThat(parsedWebhookEvent.accountHolderCreated()).isEmpty + assertThat(parsedWebhookEvent.kybPayload()).isEmpty + assertThat(parsedWebhookEvent.kycPayload()).isEmpty + assertThat(parsedWebhookEvent.legacyPayload()).isEmpty + assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()) + .contains(cardAuthorizationChallenge) + assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty + assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardCreated()).isEmpty + assertThat(parsedWebhookEvent.cardConverted()).isEmpty + assertThat(parsedWebhookEvent.cardRenewed()).isEmpty + assertThat(parsedWebhookEvent.cardReissued()).isEmpty + assertThat(parsedWebhookEvent.cardShipped()).isEmpty + assertThat(parsedWebhookEvent.cardUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataCreated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataUpdated()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationResult()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationTwoFactorAuthenticationCode()) + .isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationTwoFactorAuthenticationCodeSent()) + .isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.disputeUpdated()).isEmpty + assertThat(parsedWebhookEvent.disputeEvidenceUploadFailed()).isEmpty + assertThat(parsedWebhookEvent.externalBankAccountCreated()).isEmpty + assertThat(parsedWebhookEvent.externalBankAccountUpdated()).isEmpty + assertThat(parsedWebhookEvent.externalPaymentCreated()).isEmpty + assertThat(parsedWebhookEvent.externalPaymentUpdated()).isEmpty + assertThat(parsedWebhookEvent.financialAccountCreated()).isEmpty + assertThat(parsedWebhookEvent.financialAccountUpdated()).isEmpty + assertThat(parsedWebhookEvent.fundingEventCreated()).isEmpty + assertThat(parsedWebhookEvent.loanTapeCreated()).isEmpty + assertThat(parsedWebhookEvent.loanTapeUpdated()).isEmpty + assertThat(parsedWebhookEvent.managementOperationCreated()).isEmpty + assertThat(parsedWebhookEvent.managementOperationUpdated()).isEmpty + assertThat(parsedWebhookEvent.internalTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.internalTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.networkTotalCreated()).isEmpty + assertThat(parsedWebhookEvent.networkTotalUpdated()).isEmpty + assertThat(parsedWebhookEvent.paymentTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.paymentTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.settlementReportUpdated()).isEmpty + assertThat(parsedWebhookEvent.statementsCreated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthenticationCreated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthenticationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthenticationChallenge()).isEmpty + assertThat(parsedWebhookEvent.tokenizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationResult()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCode()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCodeSent()).isEmpty + assertThat(parsedWebhookEvent.tokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthenticationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardAuthorizationChallengeRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardAuthorizationChallenge( + CardAuthorizationChallengeWebhookEvent.builder() + .authorization( + CardAuthorization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .amounts( + CardAuthorization.Amounts.builder() + .cardholder( + CardAuthorization.Amounts.ConvertedAmount.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .merchant( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + CardAuthorization.Amounts.Amount.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(0L) + .avs( + CardAuthorization.Avs.builder() + .address("address") + .addressOnFileMatch( + CardAuthorization.Avs.AddressMatchResult.MATCH + ) + .zipcode("zipcode") + .build() + ) + .card( + CardAuthorization.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + CardAuthorization.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(CardAuthorization.AsaRequestCard.State.CLOSED) + .type(CardAuthorization.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + CardAuthorization.TransactionMerchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .phoneNumber("5551234567") + .postalCode("10001") + .streetAddress("123 MAIN ST") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .serviceLocation( + CardAuthorization.ServiceLocation.builder() + .city("city") + .country("country") + .postalCode("postal_code") + .state("state") + .streetAddress("street_address") + .build() + ) + .settledAmount(0L) + .status(CardAuthorization.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(CardAuthorization.TransactionInitiator.CARDHOLDER) + .accountType(CardAuthorization.AccountType.CHECKING) + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult( + CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy( + CardholderAuthentication.DecisionMadeBy.LITHIC_RULES + ) + .liabilityShift( + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken( + "a6e372d0-b40a-43eb-b0d1-4e1aebef5875" + ) + .build() + ) + .cashback(0L) + .conversionRate(0.0) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fleetInfo( + CardAuthorization.AsaRequestFleetInfo.builder() + .fleetPromptCode( + CardAuthorization.AsaRequestFleetInfo.FleetPromptCode + .NO_PROMPT + ) + .fleetRestrictionCode( + CardAuthorization.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + CardAuthorization.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(CardAuthorization.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(CardAuthorization.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + CardAuthorization.AsaNetworkSpecificData.builder() + .mastercard( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + CardAuthorization.AsaNetworkSpecificData + .AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + CardAuthorization.Pos.builder() + .entryMode( + CardAuthorization.Pos.AsaRequestPosEntryMode.builder() + .card( + CardAuthorization.Pos.AsaRequestPosEntryMode.Card + .PRESENT + ) + .cardholder( + CardAuthorization.Pos.AsaRequestPosEntryMode + .Cardholder + .DEFERRED_BILLING + ) + .pan( + CardAuthorization.Pos.AsaRequestPosEntryMode.Pan + .AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + CardAuthorization.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + CardAuthorization.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + CardAuthorization.Pos.AsaPosTerminal.PinCapability + .CAPABLE + ) + .type( + CardAuthorization.Pos.AsaPosTerminal.Type + .ADMINISTRATIVE + ) + .acceptorTerminalId("5([<,yN%") + .build() + ) + .build() + ) + .tokenInfo( + TokenInfo.builder() + .walletType(TokenInfo.WalletType.APPLE_PAY) + .build() + ) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .challenge( + CardAuthorizationChallengeWebhookEvent.AuthorizationChallenge.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + CardAuthorizationChallengeWebhookEvent.EventType + .CARD_AUTHORIZATION_CHALLENGE + ) .build() ) @@ -1467,6 +1910,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()) .contains(cardAuthorizationChallengeResponse) assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty @@ -1617,6 +2061,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()) .contains(authRulesBacktestReportCreated) @@ -1776,6 +2221,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).contains(balanceUpdated) @@ -1929,6 +2375,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2117,6 +2564,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2258,6 +2706,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2351,6 +2800,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2447,6 +2897,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2543,6 +2994,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2640,6 +3092,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -2739,6 +3192,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -3060,6 +3514,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -3449,6 +3904,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -3654,6 +4110,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -3884,6 +4341,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4092,6 +4550,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4244,6 +4703,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4378,6 +4838,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4537,6 +4998,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4694,6 +5156,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4812,6 +5275,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -4947,6 +5411,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -5106,6 +5571,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -5261,6 +5727,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -5413,6 +5880,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -5563,6 +6031,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -5710,6 +6179,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -5842,6 +6312,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -6107,6 +6578,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -6539,6 +7011,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -6863,6 +7336,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -7065,6 +7539,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -7237,6 +7712,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -7379,6 +7855,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -7516,6 +7993,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -7644,6 +8122,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -7816,6 +8295,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -8032,6 +8512,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -8208,6 +8689,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -8449,6 +8931,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -8804,6 +9287,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -9178,6 +9662,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -9581,6 +10066,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -9914,6 +10400,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -10108,6 +10595,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -10250,6 +10738,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -10381,6 +10870,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -10535,6 +11025,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -10810,6 +11301,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -11103,6 +11595,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty @@ -11309,6 +11802,7 @@ internal class ParsedWebhookEventTest { assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.cardAuthorizationChallenge()).isEmpty assertThat(parsedWebhookEvent.cardAuthorizationChallengeResponse()).isEmpty assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsyncTest.kt new file mode 100644 index 00000000..cdeedd75 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardAuthorizationServiceAsyncTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClientAsync +import com.lithic.api.models.CardAuthorizationChallengeResponseParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardAuthorizationServiceAsyncTest { + + @Test + fun challengeResponse() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardAuthorizationServiceAsync = client.cardAuthorizations() + + val future = + cardAuthorizationServiceAsync.challengeResponse( + CardAuthorizationChallengeResponseParams.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .response(CardAuthorizationChallengeResponseParams.Response.APPROVE) + .build() + ) + + val response = future.get() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardAuthorizationServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardAuthorizationServiceTest.kt new file mode 100644 index 00000000..fb4dcbd9 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardAuthorizationServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.CardAuthorizationChallengeResponseParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardAuthorizationServiceTest { + + @Test + fun challengeResponse() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardAuthorizationService = client.cardAuthorizations() + + cardAuthorizationService.challengeResponse( + CardAuthorizationChallengeResponseParams.builder() + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .response(CardAuthorizationChallengeResponseParams.Response.APPROVE) + .build() + ) + } +} diff --git a/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt b/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt index c5720dee..e9baef7a 100644 --- a/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt +++ b/lithic-java-proguard-test/src/test/kotlin/com/lithic/api/proguard/ProGuardCompatibilityTest.kt @@ -56,6 +56,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.tokenizationDecisioning()).isNotNull() assertThat(client.tokenizations()).isNotNull() assertThat(client.cards()).isNotNull() + assertThat(client.cardAuthorizations()).isNotNull() assertThat(client.cardBulkOrders()).isNotNull() assertThat(client.balances()).isNotNull() assertThat(client.disputes()).isNotNull()